Star64_linux/net/sched
Jamal Hadi Salim 26a926eeea net/sched: fix a qdisc modification with ambiguous command request
[ Upstream commit da71714e35 ]

When replacing an existing root qdisc, with one that is of the same kind, the
request boils down to essentially a parameterization change  i.e not one that
requires allocation and grafting of a new qdisc. syzbot was able to create a
scenario which resulted in a taprio qdisc replacing an existing taprio qdisc
with a combination of NLM_F_CREATE, NLM_F_REPLACE and NLM_F_EXCL leading to
create and graft scenario.
The fix ensures that only when the qdisc kinds are different that we should
allow a create and graft, otherwise it goes into the "change" codepath.

While at it, fix the code and comments to improve readability.

While syzbot was able to create the issue, it did not zone on the root cause.
Analysis from Vladimir Oltean <vladimir.oltean@nxp.com> helped narrow it down.

v1->V2 changes:
- remove "inline" function definition (Vladmir)
- remove extrenous braces in branches (Vladmir)
- change inline function names (Pedro)
- Run tdc tests (Victor)
v2->v3 changes:
- dont break else/if (Simon)

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reported-by: syzbot+a3618a167af2021433cd@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/20230816225759.g25x76kmgzya2gei@skbuf/T/
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Victor Nogueira <victor@mojatatu.com>
Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-05 01:25:06 +08:00
..
act_api.c net/sched: act_api: Notify user space if any actions were flushed before error 2023-04-19 17:50:53 +08:00
act_bpf.c flow_offload: fill flags to action structure 2023-04-19 17:59:30 +08:00
act_connmark.c flow_offload: fill flags to action structure 2023-04-19 17:59:30 +08:00
act_csum.c net_sched: refactor TC action init API 2021-08-02 10:24:38 +01:00
act_ct.c netfilter: conntrack: Fix data-races around ct mark 2023-04-19 17:56:36 +08:00
act_ctinfo.c net/sched: act_ctinfo: use percpu stats 2023-04-19 17:59:30 +08:00
act_gact.c net_sched: refactor TC action init API 2021-08-02 10:24:38 +01:00
act_gate.c flow_offload: fill flags to action structure 2023-04-19 17:59:30 +08:00
act_ife.c flow_offload: fill flags to action structure 2023-04-19 17:59:30 +08:00
act_ipt.c net/sched: act_ipt: add sanity checks on table name and hook locations 2023-08-20 15:24:45 +08:00
act_meta_mark.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
act_meta_skbprio.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
act_meta_skbtcindex.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
act_mirred.c net/sched: act_mirred: Add carrier check 2023-06-06 18:37:44 +08:00
act_mpls.c net/sched: act_mpls: fix action bind logic 2023-04-19 18:00:30 +08:00
act_nat.c flow_offload: fill flags to action structure 2023-04-19 17:59:30 +08:00
act_pedit.c net/sched: act_pedit: Add size check for TCA_PEDIT_PARMS_EX 2023-08-20 15:24:46 +08:00
act_police.c net: sched: act_police: fix sparse errors in tcf_police_dump() 2023-08-20 15:21:26 +08:00
act_sample.c net/sched: act_sample: fix action bind logic 2023-04-19 18:00:30 +08:00
act_simple.c flow_offload: fill flags to action structure 2023-04-19 17:59:30 +08:00
act_skbedit.c flow_offload: fill flags to action structure 2023-04-19 17:59:30 +08:00
act_skbmod.c flow_offload: fill flags to action structure 2023-04-19 17:59:30 +08:00
act_tunnel_key.c net_sched: refactor TC action init API 2021-08-02 10:24:38 +01:00
act_vlan.c net_sched: refactor TC action init API 2021-08-02 10:24:38 +01:00
cls_api.c net/sched: cls_api: Fix lockup on flushing explicitly created chain 2023-08-20 15:23:46 +08:00
cls_basic.c net_sched: refactor TC action init API 2021-08-02 10:24:38 +01:00
cls_bpf.c net: sched: cls_bpf: Undo tcf_bind_filter in case of an error 2023-08-20 16:01:11 +08:00
cls_cgroup.c net_sched: refactor TC action init API 2021-08-02 10:24:38 +01:00
cls_flow.c net_sched: refactor TC action init API 2021-08-02 10:24:38 +01:00
cls_flower.c net/sched: flower: Ensure both minimum and maximum ports are specified 2023-08-20 15:24:56 +08:00
cls_fw.c net/sched: cls_fw: No longer copy tcf_result on update to avoid use-after-free 2023-08-20 16:01:33 +08:00
cls_matchall.c net_sched: refactor TC action init API 2021-08-02 10:24:38 +01:00
cls_route.c net/sched: cls_route: No longer copy tcf_result on update to avoid use-after-free 2023-08-20 16:01:33 +08:00
cls_rsvp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cls_rsvp.h net_sched: refactor TC action init API 2021-08-02 10:24:38 +01:00
cls_rsvp6.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cls_u32.c net/sched: cls_u32: No longer copy tcf_result on update to avoid use-after-free 2023-08-20 16:01:33 +08:00
em_canid.c net: sched: kerneldoc fixes 2020-07-13 17:20:40 -07:00
em_cmp.c net: sched: fix misspellings using misspell-fixer tool 2020-11-10 17:00:28 -08:00
em_ipset.c sched: consistently handle layer3 header accesses in the presence of VLANs 2020-07-03 14:34:53 -07:00
em_ipt.c sched: consistently handle layer3 header accesses in the presence of VLANs 2020-07-03 14:34:53 -07:00
em_meta.c sched: consistently handle layer3 header accesses in the presence of VLANs 2020-07-03 14:34:53 -07:00
em_nbyte.c net: sched: Return the correct errno code 2021-02-06 11:15:28 -08:00
em_text.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
em_u32.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
ematch.c net_sched: reject TCF_EM_SIMPLE case for complex ematch module 2023-04-19 17:57:56 +08:00
Kconfig net/sched: Retire tcindex classifier 2023-04-19 18:00:26 +08:00
Makefile net/sched: Retire tcindex classifier 2023-04-19 18:00:26 +08:00
sch_api.c net/sched: fix a qdisc modification with ambiguous command request 2023-09-05 01:25:06 +08:00
sch_atm.c net: sched: atm: dont intepret cls results when asked to drop 2023-04-19 17:58:27 +08:00
sch_blackhole.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sch_cake.c net: sched: cake: fix null pointer access issue when cake_init() fails 2023-04-19 17:55:43 +08:00
sch_cbq.c net: sched: cbq: dont intepret cls results when asked to drop 2023-04-19 17:58:27 +08:00
sch_cbs.c net: don't include ethtool.h from netdevice.h 2020-11-23 17:27:04 -08:00
sch_choke.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_codel.c net: sched: Fix a possible null-pointer dereference in dequeue_func() 2019-07-29 09:46:58 -07:00
sch_drr.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_dsmark.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_etf.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_ets.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_fifo.c net_sched: fix NULL deref in fifo_set_limit() 2021-10-01 14:59:10 -07:00
sch_fq.c net/sched: sch_fq: fix integer overflow of "credit" 2023-06-06 18:37:19 +08:00
sch_fq_codel.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_fq_pie.c net/sched: fq_pie: ensure reasonable TCA_FQ_PIE_QUANTUM values 2023-08-20 15:21:24 +08:00
sch_frag.c net/sched: Extend qdisc control block with tc control block 2023-04-19 17:43:29 +08:00
sch_generic.c net/sched: fix netdevice reference leaks in attach_default_qdiscs() 2023-04-19 17:53:35 +08:00
sch_gred.c net: sched: Fix spelling mistakes 2021-05-31 22:44:56 -07:00
sch_hfsc.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_hhf.c net: Add MODULE_DESCRIPTION entries to network modules 2020-06-20 21:33:57 -07:00
sch_htb.c net: sched: sch: Fix off by one in htb_activate_prios() 2023-04-19 17:59:30 +08:00
sch_ingress.c net/sched: Reserve TC_H_INGRESS (TC_H_CLSACT) for ingress (clsact) Qdiscs 2023-08-20 15:21:01 +08:00
sch_mq.c net: sched: update default qdisc visibility after Tx queue cnt changes 2023-04-19 16:57:06 +08:00
sch_mqprio.c net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64 2023-08-20 16:01:20 +08:00
sch_multiq.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_netem.c sch_netem: fix issues in netem_change() vs get_dist_table() 2023-08-20 16:01:45 +08:00
sch_pie.c net: sched: fix misspellings using misspell-fixer tool 2020-11-10 17:00:28 -08:00
sch_plug.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sch_prio.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_qfq.c net/sched: sch_qfq: reintroduce lmax bound check for MTU 2023-08-20 16:01:07 +08:00
sch_red.c net: sched: Fix use after free in red_enqueue() 2023-04-19 17:55:57 +08:00
sch_sfb.c net: sched: sfb: fix null pointer access issue when sfb_init() fails 2023-04-19 17:55:43 +08:00
sch_sfq.c net/sched: store the last executed chain also for clsact egress 2021-07-29 22:17:37 +01:00
sch_skbprio.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_taprio.c net/sched: taprio: Limit TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME to INT_MAX. 2023-08-20 16:01:33 +08:00
sch_tbf.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00
sch_teql.c net: sched: delete duplicate cleanup of backlog and qlen 2023-04-19 17:55:43 +08:00