linux/net/sched
Daniel Borkmann 7913ecf69e net: cls_bpf: fix size mismatch on filter preparation
In cls_bpf_modify_existing(), we read out the number of filter blocks,
do some sanity checks, allocate a block on that size, and copy over the
BPF instruction blob from user space, then pass everything through the
classic BPF checker prior to installation of the classifier.

We should reject mismatches here, there are 2 scenarios: the number of
filter blocks could be smaller than the provided instruction blob, so
we do a partial copy of the BPF program, and thus the instructions will
either be rejected from the verifier or a valid BPF program will be run;
in the other case, we'll end up copying more than we're supposed to,
and most likely the trailing garbage will be rejected by the verifier
as well (i.e. we need to fit instruction pattern, ret {A,K} needs to be
last instruction, load/stores must be correct, etc); in case not, we
would leak memory when dumping back instruction patterns. The code should
have only used nla_len() as Dave noted to avoid this from the beginning.
Anyway, lets fix it by rejecting such load attempts.

Fixes: 7d1d65cb84 ("net: sched: cls_bpf: add BPF-based classifier")
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-01-26 15:50:18 -08:00
..
Kconfig Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2014-12-10 15:48:20 -05:00
Makefile sched: introduce vlan action 2014-11-21 14:20:18 -05:00
act_api.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
act_csum.c net_sched: act: move tcf_hashinfo_init() into tcf_register_action() 2014-02-12 19:23:32 -05:00
act_gact.c sched: fix act file names in header comment 2014-11-06 15:04:41 -05:00
act_ipt.c sched: fix act file names in header comment 2014-11-06 15:04:41 -05:00
act_mirred.c sched: fix act file names in header comment 2014-11-06 15:04:41 -05:00
act_nat.c net_sched: act: move tcf_hashinfo_init() into tcf_register_action() 2014-02-12 19:23:32 -05:00
act_pedit.c sched: fix act file names in header comment 2014-11-06 15:04:41 -05:00
act_police.c sched: fix act file names in header comment 2014-11-06 15:04:41 -05:00
act_simple.c sched: fix act file names in header comment 2014-11-06 15:04:41 -05:00
act_skbedit.c net_sched: act: move tcf_hashinfo_init() into tcf_register_action() 2014-02-12 19:23:32 -05:00
act_vlan.c sched: introduce vlan action 2014-11-21 14:20:18 -05:00
cls_api.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2014-10-08 16:22:22 -04:00
cls_basic.c net: sched: cls_basic: fix error path in basic_change() 2014-12-09 15:41:56 -05:00
cls_bpf.c net: cls_bpf: fix size mismatch on filter preparation 2015-01-26 15:50:18 -08:00
cls_cgroup.c net: sched: cls: use nla_nest_cancel instead of nlmsg_trim 2014-12-09 21:49:58 -05:00
cls_flow.c net: sched: cls: use nla_nest_cancel instead of nlmsg_trim 2014-12-09 21:49:58 -05:00
cls_fw.c net: sched: cls: use nla_nest_cancel instead of nlmsg_trim 2014-12-09 21:49:58 -05:00
cls_route.c net: sched: cls: use nla_nest_cancel instead of nlmsg_trim 2014-12-09 21:49:58 -05:00
cls_rsvp.c [NET_SCHED]: Remove unnecessary includes 2007-07-10 22:16:41 -07:00
cls_rsvp.h net: sched: cls: use nla_nest_cancel instead of nlmsg_trim 2014-12-09 21:49:58 -05:00
cls_rsvp6.c [NET_SCHED]: Remove unnecessary includes 2007-07-10 22:16:41 -07:00
cls_tcindex.c net: sched: cls: use nla_nest_cancel instead of nlmsg_trim 2014-12-09 21:49:58 -05:00
cls_u32.c net: sched: cls: remove unused op put from tcf_proto_ops 2014-12-09 14:49:02 -05:00
em_canid.c net: sched: remove tcf_proto from ematch calls 2014-10-06 18:02:32 -04:00
em_cmp.c net_sched: cleanups 2011-01-19 23:31:12 -08:00
em_ipset.c net: sched: remove tcf_proto from ematch calls 2014-10-06 18:02:32 -04:00
em_meta.c net: sched: remove tcf_proto from ematch calls 2014-10-06 18:02:32 -04:00
em_nbyte.c net: sched: remove tcf_proto from ematch calls 2014-10-06 18:02:32 -04:00
em_text.c net: sched: remove tcf_proto from ematch calls 2014-10-06 18:02:32 -04:00
em_u32.c net_sched: cleanups 2011-01-19 23:31:12 -08:00
ematch.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2014-10-08 16:22:22 -04:00
sch_api.c net: sched: initialize bstats syncp 2014-10-21 21:45:21 -04:00
sch_atm.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_blackhole.c pkt_sched: Add qdisc->ops->peek() implementation. 2008-10-31 00:45:55 -07:00
sch_cbq.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_choke.c net: sched: implement qstat helper routines 2014-09-30 01:02:26 -04:00
sch_codel.c net: sched: implement qstat helper routines 2014-09-30 01:02:26 -04:00
sch_drr.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_dsmark.c net: sched: implement qstat helper routines 2014-09-30 01:02:26 -04:00
sch_fifo.c net: sched: implement qstat helper routines 2014-09-30 01:02:26 -04:00
sch_fq.c pkt_sched: fq: increase max delay from 125 ms to one second 2014-11-26 12:08:04 -05:00
sch_fq_codel.c net: fix suspicious rcu_dereference_check in net/sched/sch_fq_codel.c 2014-12-09 21:49:09 -05:00
sch_generic.c net_sched: restore qdisc quota fairness limits after bulk dequeue 2014-10-09 19:12:26 -04:00
sch_gred.c net: sched: implement qstat helper routines 2014-09-30 01:02:26 -04:00
sch_hfsc.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_hhf.c net: sched: implement qstat helper routines 2014-09-30 01:02:26 -04:00
sch_htb.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_ingress.c net: sched: implement qstat helper routines 2014-09-30 01:02:26 -04:00
sch_mq.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_mqprio.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_multiq.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_netem.c net: add rbnode to struct sk_buff 2014-11-03 16:13:03 -05:00
sch_pie.c sch_pie: schedule the timer after all init succeed 2014-10-29 14:28:01 -04:00
sch_plug.c net_sched: sch_plug: plug_qdisc_ops is static 2012-02-13 16:04:40 -05:00
sch_prio.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_qfq.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_red.c net: sched: implement qstat helper routines 2014-09-30 01:02:26 -04:00
sch_sfb.c net: sched: implement qstat helper routines 2014-09-30 01:02:26 -04:00
sch_sfq.c net: sched: enable per cpu qstats 2014-09-30 01:02:26 -04:00
sch_tbf.c net: sched: avoid costly atomic operation in fq_dequeue() 2014-10-06 00:55:10 -04:00
sch_teql.c net: better IFF_XMIT_DST_RELEASE support 2014-10-07 13:22:11 -04:00