linux/net
Lion Ackermann f680a4643c net/sched: Always pass notifications when child class becomes empty
[ Upstream commit 103406b38c ]

Certain classful qdiscs may invoke their classes' dequeue handler on an
enqueue operation. This may unexpectedly empty the child qdisc and thus
make an in-flight class passive via qlen_notify(). Most qdiscs do not
expect such behaviour at this point in time and may re-activate the
class eventually anyways which will lead to a use-after-free.

The referenced fix commit attempted to fix this behavior for the HFSC
case by moving the backlog accounting around, though this turned out to
be incomplete since the parent's parent may run into the issue too.
The following reproducer demonstrates this use-after-free:

    tc qdisc add dev lo root handle 1: drr
    tc filter add dev lo parent 1: basic classid 1:1
    tc class add dev lo parent 1: classid 1:1 drr
    tc qdisc add dev lo parent 1:1 handle 2: hfsc def 1
    tc class add dev lo parent 2: classid 2:1 hfsc rt m1 8 d 1 m2 0
    tc qdisc add dev lo parent 2:1 handle 3: netem
    tc qdisc add dev lo parent 3:1 handle 4: blackhole

    echo 1 | socat -u STDIN UDP4-DATAGRAM:127.0.0.1:8888
    tc class delete dev lo classid 1:1
    echo 1 | socat -u STDIN UDP4-DATAGRAM:127.0.0.1:8888

Since backlog accounting issues leading to a use-after-frees on stale
class pointers is a recurring pattern at this point, this patch takes
a different approach. Instead of trying to fix the accounting, the patch
ensures that qdisc_tree_reduce_backlog always calls qlen_notify when
the child qdisc is empty. This solves the problem because deletion of
qdiscs always involves a call to qdisc_reset() and / or
qdisc_purge_queue() which ultimately resets its qlen to 0 thus causing
the following qdisc_tree_reduce_backlog() to report to the parent. Note
that this may call qlen_notify on passive classes multiple times. This
is not a problem after the recent patch series that made all the
classful qdiscs qlen_notify() handlers idempotent.

Fixes: 3f98113810 ("sch_hfsc: Fix qlen accounting bug when using peek in hfsc_enqueue()")
Signed-off-by: Lion Ackermann <nnamrec@gmail.com>
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Link: https://patch.msgid.link/d912cbd7-193b-4269-9857-525bee8bbb6a@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-07-10 16:03:12 +02:00
..
6lowpan 6lowpan: Remove redundant initialisation. 2023-03-29 08:22:52 +01:00
9p 9p/net: fix improper handling of bogus negative read/write replies 2025-05-02 07:50:56 +02:00
802 net: 802: LLC+SNAP OID:PID lookup on start of skb data 2025-01-17 13:36:11 +01:00
8021q net: vlan: don't propagate flags on open 2025-04-25 10:45:16 +02:00
appletalk appletalk: Fix Use-After-Free in atalk_ioctl 2023-12-20 17:01:50 +01:00
atm atm: Release atm_dev_mutex after removing procfs in atm_dev_deregister(). 2025-07-06 11:00:12 +02:00
ax25 ax25: Fix refcount leak caused by setting SO_BINDTODEVICE sockopt 2025-02-21 13:57:06 +01:00
batman-adv batman-adv: Ignore own maximum aggregation size during RX 2025-03-28 21:59:55 +01:00
bluetooth Bluetooth: Prevent unintended pause by checking if advertising is active 2025-07-10 16:03:07 +02:00
bpf bpf, test_run: Fix use-after-free issue in eth_skb_pkt_type() 2025-02-27 04:10:50 -08:00
bpfilter net: Use umd_cleanup_helper() 2023-05-31 13:06:57 +02:00
bridge net: bridge: mcast: re-implement br_multicast_{enable, disable}_port functions 2025-06-27 11:08:55 +01:00
caif sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES) 2023-06-24 15:50:13 -07:00
can can: bcm: add missing rcu read protection for procfs content 2025-06-04 14:42:19 +02:00
ceph ceph: allocate sparse_ext map only for sparse reads 2025-01-02 10:32:00 +01:00
core net: selftests: fix TCP packet checksum 2025-07-06 11:00:12 +02:00
dcb net: dcb: choose correct policy to parse DCB_ATTR_BCN 2023-08-01 21:07:46 -07:00
dccp net: fix data-races around sk->sk_forward_alloc 2025-01-23 17:21:19 +01:00
devlink devlink: fix port new reply cmd type 2024-03-26 18:20:11 -04:00
dns_resolver keys, dns: Fix size check of V1 server-list header 2024-01-25 15:35:41 -08:00
dsa net: dsa: tag_brcm: legacy: fix pskb_may_pull length 2025-06-19 15:28:33 +02:00
ethernet ethernet: Add helper for assigning packet type when dest address does not match device address 2024-05-02 16:32:46 +02:00
ethtool net: ethtool: Don't call .cleanup_data when prepare_data fails 2025-04-25 10:45:07 +02:00
handshake net/handshake: Fix handshake_req_destroy_test1 2024-02-23 09:24:50 +01:00
hsr net: hsr: fix fill_frame_info() regression vs VLAN packets 2025-02-08 09:52:32 +01:00
ieee802154 net: Rename mono_delivery_time to tstamp_type for scalabilty 2025-05-09 09:43:57 +02:00
ife net: sched: ife: fix potential use-after-free 2024-01-01 12:42:30 +00:00
ipv4 tcp: fix passive TFO socket having invalid NAPI ID 2025-06-27 11:09:02 +01:00
ipv6 Revert "ipv6: save dontfrag in cork" 2025-07-06 11:00:16 +02:00
iucv s390/iucv: MSG_PEEK causes memory leak in iucv_sock_destruct() 2024-12-09 10:32:33 +01:00
kcm kcm: Serialise kcm_sendmsg() for the same socket. 2024-08-29 17:33:46 +02:00
key Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-08-18 12:44:56 -07:00
l2tp ipv6: introduce dst_rt6_info() helper 2024-12-14 19:59:35 +01:00
l3mdev l3mdev: l3mdev_master_upper_ifindex_by_index_rcu should be using netdev_master_upper_dev_get_rcu 2022-04-15 14:27:24 -07:00
lapb net: lapb: Use list_for_each_entry() to simplify code in lapb_iface.c 2021-06-08 16:31:25 -07:00
llc llc: fix data loss when reading from a socket in llc_ui_recvmsg() 2025-06-04 14:42:20 +02:00
mac80211 wifi: mac80211: fix beacon interval calculation overflow 2025-07-06 11:00:12 +02:00
mac802154 mac802154: check local interfaces before deleting sdata list 2025-01-23 17:21:13 +01:00
mctp net: mctp: Ensure keys maintain only one ref to corresponding dev 2025-05-22 14:12:16 +02:00
mpls mpls: Use rcu_dereference_rtnl() in mpls_route_input_rcu(). 2025-06-27 11:09:02 +01:00
mptcp mptcp: sockopt: fix getting freebind & transparent 2025-04-25 10:45:54 +02:00
ncsi net: ncsi: Fix GCPS 64-bit member variables 2025-06-19 15:28:10 +02:00
netfilter netfilter: nf_nat: also check reverse tuple to obtain clashing entry 2025-06-19 15:28:34 +02:00
netlabel calipso: unlock rcu before returning -EAFNOSUPPORT 2025-06-19 15:28:46 +02:00
netlink sock_diag: add module pointer to "struct sock_diag_handler" 2024-12-09 10:32:09 +01:00
netrom netrom: check buffer length before accessing it 2025-01-09 13:32:00 +01:00
nfc NFC: nci: uart: Set tty->disc_data only in success path 2025-06-27 11:08:48 +01:00
nsh nsh: Restore skb->{protocol,data,mac_header} for outer header in nsh_gso_segment(). 2024-05-17 12:02:02 +02:00
openvswitch net: openvswitch: Fix the dead loop of MPLS parse 2025-06-19 15:28:19 +02:00
packet af_packet: fix vlan_get_protocol_dgram() vs MSG_PEEK 2025-01-09 13:32:02 +01:00
phonet phonet: Handle error of rtnl_register_module(). 2024-10-17 15:24:30 +02:00
psample psample: Require 'CAP_NET_ADMIN' when joining "packets" group 2023-12-13 18:45:10 +01:00
qrtr net: qrtr: Update packets cloning when broadcasting 2024-10-04 16:29:41 +02:00
rds net:rds: Fix possible deadlock in rds_message_put 2024-08-19 06:04:27 +02:00
rfkill net: rfkill: gpio: Add check for clk_enable() 2024-12-09 10:32:11 +01:00
rose rose: fix dangling neighbour pointers in rose_rt_device_down() 2025-07-10 16:03:11 +02:00
rxrpc rxrpc: rxperf: Fix missing decoding of terminal magic cookie 2025-03-07 16:45:38 +01:00
sched net/sched: Always pass notifications when child class becomes empty 2025-07-10 16:03:12 +02:00
sctp sctp: Do not wake readers in __sctp_write_space() 2025-06-27 11:08:53 +01:00
smc net/smc: use the correct ndev to find pnetid by pnetid table 2025-06-04 14:41:59 +02:00
strparser strparser: Add read_sock callback 2025-02-27 04:10:50 -08:00
sunrpc sunrpc: don't immediately retransmit on seqno miss 2025-07-06 11:00:05 +02:00
switchdev net: switchdev: Convert blocking notification chain to a raw one 2025-03-22 12:50:39 -07:00
tipc tipc: fix null-ptr-deref when acquiring remote ip of ethernet bearer 2025-06-27 11:09:02 +01:00
tls ktls, sockmap: Fix missing uncharge operation 2025-06-19 15:28:15 +02:00
unix af_unix: Don't set -ECONNRESET for consumed OOB skb. 2025-07-06 11:00:12 +02:00
vmw_vsock vsock/vmci: Clear the vmci transport packet properly when initializing it 2025-07-10 16:03:04 +02:00
wireless wifi: cfg80211: init wiphy_work before allocating rfkill fails 2025-06-27 11:09:00 +01:00
x25 net/x25: fix incorrect parameter validation in the x25_getsockopt() function 2024-03-26 18:19:41 -04:00
xdp xsk: fix an integer overflow in xp_create_and_assign_umem() 2025-03-28 21:59:55 +01:00
xfrm xfrm: Use xdo.dev instead of xdo.real_dev 2025-06-19 15:28:11 +02:00
compat.c net/compat: Update msg_control_is_user when setting a kernel pointer 2023-04-14 11:09:27 +01:00
devres.c net: devres: Correct a grammatical error 2021-06-11 12:55:28 -07:00
Kconfig bpf: Add fd-based tcx multi-prog infra with link support 2023-07-19 10:07:27 -07:00
Kconfig.debug net: make NET_(DEV|NS)_REFCNT_TRACKER depend on NET 2022-09-20 14:23:56 -07:00
Makefile af_unix: Remove CONFIG_UNIX_SCM. 2025-06-04 14:42:22 +02:00
socket.c net: explicitly clear the sk pointer, when pf->create fails 2024-10-17 15:24:35 +02:00
sysctl_net.c sysctl: treewide: drop unused argument ctl_table_root::set_ownership(table) 2024-08-11 12:47:13 +02:00