linux-stable/net/sched
Jamal Hadi Salim 99b25b8778 net_sched: cls_route: disallow handle of 0
commit 0279957171 upstream.

Follows up on:
https://lore.kernel.org/all/20220809170518.164662-1-cascardo@canonical.com/

handle of 0 implies from/to of universe realm which is not very
sensible.

Lets see what this patch will do:
$sudo tc qdisc add dev $DEV root handle 1:0 prio

//lets manufacture a way to insert handle of 0
$sudo tc filter add dev $DEV parent 1:0 protocol ip prio 100 \
route to 0 from 0 classid 1:10 action ok

//gets rejected...
Error: handle of 0 is not valid.
We have an error talking to the kernel, -1

//lets create a legit entry..
sudo tc filter add dev $DEV parent 1:0 protocol ip prio 100 route from 10 \
classid 1:10 action ok

//what did the kernel insert?
$sudo tc filter ls dev $DEV parent 1:0
filter protocol ip pref 100 route chain 0
filter protocol ip pref 100 route chain 0 fh 0x000a8000 flowid 1:10 from 10
	action order 1: gact action pass
	 random type none pass val 0
	 index 1 ref 1 bind 1

//Lets try to replace that legit entry with a handle of 0
$ sudo tc filter replace dev $DEV parent 1:0 protocol ip prio 100 \
handle 0x000a8000 route to 0 from 0 classid 1:10 action drop

Error: Replacing with handle of 0 is invalid.
We have an error talking to the kernel, -1

And last, lets run Cascardo's POC:
$ ./poc
0
0
-22
-22
-22

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-08-25 11:11:30 +02:00
..
act_api.c net: sched: limit TC_ACT_REPEAT loops 2022-02-23 11:57:35 +01:00
act_bpf.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_connmark.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_csum.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_gact.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_ife.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_ipt.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_meta_mark.c
act_meta_skbprio.c
act_meta_skbtcindex.c
act_mirred.c act_mirred: Fix mirred_init_module error handling 2020-01-27 14:46:49 +01:00
act_nat.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_pedit.c net/sched: act_pedit: fix WARN() in the traffic path 2019-12-01 09:13:11 +01:00
act_police.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_sample.c net/sched: act_sample: don't push mac header on ip6gre ingress 2019-10-05 12:47:40 +02:00
act_simple.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_skbedit.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_skbmod.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_tunnel_key.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
act_vlan.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:32:20 +01:00
cls_api.c net_sched: refetch skb protocol for each filter 2019-01-31 08:13:41 +01:00
cls_basic.c cls_basic: use tcf_exts_get_net() before call_rcu() 2017-11-09 10:03:09 +09:00
cls_bpf.c cls_bpf: don't decrement net's refcount when offload fails 2017-12-17 15:07:59 +01:00
cls_cgroup.c cls_cgroup: use tcf_exts_get_net() before call_rcu() 2017-11-09 10:03:09 +09:00
cls_flow.c cls_flow: use tcf_exts_get_net() before call_rcu() 2017-11-09 10:03:09 +09:00
cls_flower.c net: sched: correct flower port blocking 2020-03-11 18:02:48 +01:00
cls_fw.c cls_fw: use tcf_exts_get_net() before call_rcu() 2017-11-09 10:03:09 +09:00
cls_matchall.c net/sched: matchall: add missing validation of TCA_MATCHALL_FLAGS 2020-02-28 16:36:09 +01:00
cls_route.c net_sched: cls_route: disallow handle of 0 2022-08-25 11:11:30 +02:00
cls_rsvp.c
cls_rsvp.h cls_rsvp: fix rsvp_policy 2020-02-14 16:32:06 -05:00
cls_rsvp6.c
cls_tcindex.c net: sched: fix warning in tcindex_alloc_perfect_hash 2021-07-20 16:17:38 +02:00
cls_u32.c net/sched: cls_u32: fix netns refcount changes in u32_change() 2022-05-12 12:17:04 +02:00
em_canid.c
em_cmp.c
em_ipset.c
em_meta.c
em_nbyte.c
em_text.c
em_u32.c
ematch.c net_sched: ematch: reject invalid TCF_EM_SIMPLE 2020-02-05 14:18:09 +00:00
Kconfig
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sch_api.c net: sched: avoid duplicates in classes dump 2021-03-17 16:34:29 +01:00
sch_atm.c net_sched: fix a memory leak in atm_tc_init() 2020-07-22 09:22:20 +02:00
sch_blackhole.c net_sched: blackhole: tell upper qdisc about dropped packets 2018-07-22 14:28:46 +02:00
sch_cbq.c net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed 2021-09-22 11:45:22 +02:00
sch_choke.c net: sched: validate stab values 2021-03-30 14:40:12 +02:00
sch_codel.c net: sched: Fix a possible null-pointer dereference in dequeue_func() 2019-08-09 17:53:35 +02:00
sch_drr.c net_sched: remove tc class reference counting 2017-08-25 17:19:10 -07:00
sch_dsmark.c sch_dsmark: fix a NULL deref in qdisc_reset() 2021-06-03 08:36:25 +02:00
sch_fifo.c net_sched: fix NULL deref in fifo_set_limit() 2021-10-17 10:08:33 +02:00
sch_fq.c net: fq: add missing attribute validation for orphan mask 2020-03-20 10:54:11 +01:00
sch_fq_codel.c fq_codel: fix TCA_FQ_CODEL_DROP_BATCH_SIZE sanity checks 2020-05-20 08:16:53 +02:00
sch_generic.c net_sched: restore "mpu xxx" handling 2022-01-27 09:01:01 +01:00
sch_gred.c net: sched: validate stab values 2021-03-30 14:40:12 +02:00
sch_hfsc.c net_sched/hfsc: fix curve activation in hfsc_change_class() 2017-09-21 11:56:32 -07:00
sch_hhf.c net/flow_dissector: switch to siphash 2019-11-10 11:25:37 +01:00
sch_htb.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-09-01 17:42:05 -07:00
sch_ingress.c net: sched: fix static key imbalance in case of ingress/clsact_init error 2018-01-02 20:31:12 +01:00
sch_mq.c net: sched: fix tc -s class show no bstats on class with nolock subqueues 2019-12-05 15:38:19 +01:00
sch_mqprio.c net: sched: fix tc -s class show no bstats on class with nolock subqueues 2019-12-05 15:38:19 +01:00
sch_multiq.c net: sched: fix tc -s class show no bstats on class with nolock subqueues 2019-12-05 15:38:19 +01:00
sch_netem.c net: netem: correct the parent's backlog when corrupted packet was dropped 2020-01-27 14:46:50 +01:00
sch_pie.c
sch_plug.c
sch_prio.c net: sch_prio: When ungrafting, replace with FIFO 2020-01-12 12:12:08 +01:00
sch_qfq.c sch_qfq: prevent shift-out-of-bounds in qfq_init_qdisc 2022-01-11 13:57:36 +01:00
sch_red.c net: sched: validate stab values 2021-03-30 14:40:12 +02:00
sch_sfb.c net/flow_dissector: switch to siphash 2019-11-10 11:25:37 +01:00
sch_sfq.c net: sched: validate stab values 2021-03-30 14:40:12 +02:00
sch_tbf.c net: create skb_gso_validate_mac_len() 2019-02-20 10:20:48 +01:00
sch_teql.c net: sched: sch_teql: fix null-pointer dereference 2021-04-16 11:57:48 +02:00