sst-linux/net/sched
Toke Høiland-Jørgensen a777e06dfc sched: sch_cake: add bounds checks to host bulk flow fairness counts
[ Upstream commit 737d4d91d35b5f7fa5bb442651472277318b0bfd ]

Even though we fixed a logic error in the commit cited below, syzbot
still managed to trigger an underflow of the per-host bulk flow
counters, leading to an out of bounds memory access.

To avoid any such logic errors causing out of bounds memory accesses,
this commit factors out all accesses to the per-host bulk flow counters
to a series of helpers that perform bounds-checking before any
increments and decrements. This also has the benefit of improving
readability by moving the conditional checks for the flow mode into
these helpers, instead of having them spread out throughout the
code (which was the cause of the original logic error).

As part of this change, the flow quantum calculation is consolidated
into a helper function, which means that the dithering applied to the
ost load scaling is now applied both in the DRR rotation and when a
sparse flow's quantum is first initiated. The only user-visible effect
of this is that the maximum packet size that can be sent while a flow
stays sparse will now vary with +/- one byte in some cases. This should
not make a noticeable difference in practice, and thus it's not worth
complicating the code to preserve the old behaviour.

Fixes: 546ea84d07e3 ("sched: sch_cake: fix bulk flow accounting logic for host fairness")
Reported-by: syzbot+f63600d288bfb7057424@syzkaller.appspotmail.com
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Acked-by: Dave Taht <dave.taht@gmail.com>
Link: https://patch.msgid.link/20250107120105.70685-1-toke@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-01-17 13:34:40 +01:00
..
act_api.c net: use unrcu_pointer() helper 2024-12-14 19:53:33 +01:00
act_bpf.c
act_connmark.c
act_csum.c
act_ct.c sched: act_ct: take care of padding in struct zones_ht_key 2024-08-11 12:35:56 +02:00
act_ctinfo.c
act_gact.c
act_gate.c
act_ife.c
act_ipt.c
act_meta_mark.c
act_meta_skbprio.c
act_meta_skbtcindex.c
act_mirred.c
act_mpls.c
act_nat.c
act_pedit.c net/sched: act_pedit: Add size check for TCA_PEDIT_PARMS_EX 2023-07-19 16:22:05 +02:00
act_police.c
act_sample.c
act_simple.c
act_skbedit.c
act_skbmod.c net/sched: act_skbmod: prevent kernel-infoleak 2024-04-10 16:28:26 +02:00
act_tunnel_key.c
act_vlan.c
cls_api.c
cls_basic.c
cls_bpf.c net: sched: cls_bpf: Undo tcf_bind_filter in case of an error 2023-07-27 08:50:41 +02:00
cls_cgroup.c
cls_flow.c net_sched: cls_flow: validate TCA_FLOW_RSHIFT attribute 2025-01-17 13:34:38 +01:00
cls_flower.c net: sched: fix erspan_opt settings in cls_flower 2024-12-14 19:54:23 +01:00
cls_fw.c net/sched: cls_fw: No longer copy tcf_result on update to avoid use-after-free 2023-08-11 12:08:15 +02:00
cls_matchall.c net: sched: cls_matchall: Undo tcf_bind_filter in case of failure after mall_set_parms 2023-07-27 08:50:41 +02:00
cls_route.c net/sched: cls_route: No longer copy tcf_result on update to avoid use-after-free 2023-08-11 12:08:16 +02:00
cls_u32.c net: sched: cls_u32: Fix u32's systematic failure to free IDR entries for hnodes. 2024-11-22 15:37:30 +01:00
em_canid.c
em_cmp.c
em_ipset.c
em_ipt.c
em_meta.c net: annotate data-races around sk->sk_lingertime 2023-09-13 09:42:33 +02:00
em_nbyte.c
em_text.c net: sched: em_text: fix possible memory leak in em_text_destroy() 2024-01-10 17:10:23 +01:00
em_u32.c
ematch.c
Kconfig net/sched: Retire dsmark qdisc 2024-03-01 13:26:24 +01:00
Makefile net/sched: Retire dsmark qdisc 2024-03-01 13:26:24 +01:00
sch_api.c net/sched: stop qdisc_tree_reduce_backlog on TC_H_ROOT 2024-11-08 16:26:41 +01:00
sch_blackhole.c
sch_cake.c sched: sch_cake: add bounds checks to host bulk flow fairness counts 2025-01-17 13:34:40 +01:00
sch_cbs.c net/sched: cbs: Fix integer overflow in cbs_set_port_rate() 2024-12-14 19:54:40 +01:00
sch_choke.c net: sched: fix ordering of qlen adjustment 2024-12-27 13:52:51 +01:00
sch_codel.c
sch_drr.c
sch_etf.c
sch_ets.c
sch_fifo.c
sch_fq_codel.c
sch_fq_pie.c net/sched: fq_pie: avoid stalls in fq_pie_timer() 2023-09-19 12:28:00 +02:00
sch_fq.c
sch_frag.c
sch_generic.c net: fix races in netdev_tx_sent_queue()/dev_watchdog() 2024-11-01 01:56:04 +01:00
sch_gred.c
sch_hfsc.c net/sched: sch_hfsc: upgrade 'rt' to 'sc' when it becomes a inner curve 2023-10-25 12:03:07 +02:00
sch_hhf.c
sch_htb.c net/sched: fix false lockdep warning on qdisc root lock 2024-06-27 13:46:15 +02:00
sch_ingress.c
sch_mq.c
sch_mqprio.c net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64 2023-08-03 10:24:02 +02:00
sch_multiq.c net: sched: sch_multiq: fix possible OOB write in multiq_tune() 2024-06-21 14:35:33 +02:00
sch_netem.c net/sched: netem: account for backlog updates from child qdisc 2024-12-19 18:08:56 +01:00
sch_pie.c
sch_plug.c net: sched: sch_qfq: Fix UAF in qfq_dequeue() 2023-09-19 12:28:02 +02:00
sch_prio.c
sch_qfq.c net: sched: sch_qfq: Fix UAF in qfq_dequeue() 2023-09-19 12:28:02 +02:00
sch_red.c
sch_sfb.c
sch_sfq.c
sch_skbprio.c
sch_taprio.c net/sched: taprio: extend minimum interval restriction to entire cycle too 2024-11-22 15:37:34 +01:00
sch_tbf.c net/sched: tbf: correct backlog statistic for GSO packets 2024-12-14 19:54:21 +01:00
sch_teql.c