linux-stable/net
Davide Caratti d69f4a258c net/sched: ets: use old 'nbands' while purging unused classes
commit 87c6efc5ce upstream.

Shuang reported sch_ets test-case [1] crashing in ets_class_qlen_notify()
after recent changes from Lion [2]. The problem is: in ets_qdisc_change()
we purge unused DWRR queues; the value of 'q->nbands' is the new one, and
the cleanup should be done with the old one. The problem is here since my
first attempts to fix ets_qdisc_change(), but it surfaced again after the
recent qdisc len accounting fixes. Fix it purging idle DWRR queues before
assigning a new value of 'q->nbands', so that all purge operations find a
consistent configuration:

 - old 'q->nbands' because it's needed by ets_class_find()
 - old 'q->nstrict' because it's needed by ets_class_is_strict()

 BUG: kernel NULL pointer dereference, address: 0000000000000000
 #PF: supervisor read access in kernel mode
 #PF: error_code(0x0000) - not-present page
 PGD 0 P4D 0
 Oops: Oops: 0000 [#1] SMP NOPTI
 CPU: 62 UID: 0 PID: 39457 Comm: tc Kdump: loaded Not tainted 6.12.0-116.el10.x86_64 #1 PREEMPT(voluntary)
 Hardware name: Dell Inc. PowerEdge R640/06DKY5, BIOS 2.12.2 07/09/2021
 RIP: 0010:__list_del_entry_valid_or_report+0x4/0x80
 Code: ff 4c 39 c7 0f 84 39 19 8e ff b8 01 00 00 00 c3 cc cc cc cc 66 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa <48> 8b 17 48 8b 4f 08 48 85 d2 0f 84 56 19 8e ff 48 85 c9 0f 84 ab
 RSP: 0018:ffffba186009f400 EFLAGS: 00010202
 RAX: 00000000000000d6 RBX: 0000000000000000 RCX: 0000000000000004
 RDX: ffff9f0fa29b69c0 RSI: 0000000000000000 RDI: 0000000000000000
 RBP: ffffffffc12c2400 R08: 0000000000000008 R09: 0000000000000004
 R10: ffffffffffffffff R11: 0000000000000004 R12: 0000000000000000
 R13: ffff9f0f8cfe0000 R14: 0000000000100005 R15: 0000000000000000
 FS:  00007f2154f37480(0000) GS:ffff9f269c1c0000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 0000000000000000 CR3: 00000001530be001 CR4: 00000000007726f0
 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
 PKRU: 55555554
 Call Trace:
  <TASK>
  ets_class_qlen_notify+0x65/0x90 [sch_ets]
  qdisc_tree_reduce_backlog+0x74/0x110
  ets_qdisc_change+0x630/0xa40 [sch_ets]
  __tc_modify_qdisc.constprop.0+0x216/0x7f0
  tc_modify_qdisc+0x7c/0x120
  rtnetlink_rcv_msg+0x145/0x3f0
  netlink_rcv_skb+0x53/0x100
  netlink_unicast+0x245/0x390
  netlink_sendmsg+0x21b/0x470
  ____sys_sendmsg+0x39d/0x3d0
  ___sys_sendmsg+0x9a/0xe0
  __sys_sendmsg+0x7a/0xd0
  do_syscall_64+0x7d/0x160
  entry_SYSCALL_64_after_hwframe+0x76/0x7e
 RIP: 0033:0x7f2155114084
 Code: 89 02 b8 ff ff ff ff eb bb 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa 80 3d 25 f0 0c 00 00 74 13 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 48 83 ec 28 89 54 24 1c 48 89
 RSP: 002b:00007fff1fd7a988 EFLAGS: 00000202 ORIG_RAX: 000000000000002e
 RAX: ffffffffffffffda RBX: 0000560ec063e5e0 RCX: 00007f2155114084
 RDX: 0000000000000000 RSI: 00007fff1fd7a9f0 RDI: 0000000000000003
 RBP: 00007fff1fd7aa60 R08: 0000000000000010 R09: 000000000000003f
 R10: 0000560ee9b3a010 R11: 0000000000000202 R12: 00007fff1fd7aae0
 R13: 000000006891ccde R14: 0000560ec063e5e0 R15: 00007fff1fd7aad0
  </TASK>

 [1] https://lore.kernel.org/netdev/e08c7f4a6882f260011909a868311c6e9b54f3e4.1639153474.git.dcaratti@redhat.com/
 [2] https://lore.kernel.org/netdev/d912cbd7-193b-4269-9857-525bee8bbb6a@gmail.com/

Cc: stable@vger.kernel.org
Fixes: 103406b38c ("net/sched: Always pass notifications when child class becomes empty")
Fixes: c062f2a0b0 ("net/sched: sch_ets: don't remove idle classes from the round-robin list")
Fixes: dcc68b4d80 ("net: sch_ets: Add a new Qdisc")
Reported-by: Li Shuang <shuali@redhat.com>
Closes: https://issues.redhat.com/browse/RHEL-108026
Reviewed-by: Petr Machata <petrm@nvidia.com>
Co-developed-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Link: https://patch.msgid.link/7928ff6d17db47a2ae7cc205c44777b1f1950545.1755016081.git.dcaratti@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-08-20 18:36:32 +02:00
..
6lowpan
9p
802
8021q net: vlan: fix VLAN 0 refcount imbalance of toggling filtering during runtime 2025-07-24 08:58:39 +02:00
appletalk net: appletalk: Fix use-after-free in AARP proxy probe 2025-08-01 09:51:25 +01:00
atm atm: clip: Fix NULL pointer dereference in vcc_sendmsg() 2025-07-17 18:43:42 +02:00
ax25
batman-adv
bluetooth Bluetooth: hci_sock: Reset cookie to zero in hci_sock_free_cookie() 2025-08-20 18:36:01 +02:00
bpf
bridge net: bridge: Do not offload IGMP/MLD messages 2025-07-24 08:58:39 +02:00
caif caif: reduce stack size, again 2025-08-15 12:16:25 +02:00
can
ceph
core net: ieee8021q: fix insufficient table-size assertion 2025-08-20 18:36:09 +02:00
dcb
dccp
devlink
dns_resolver
dsa
ethernet
ethtool
handshake
hsr
ieee802154
ife
ipv4 net: ipv4: fix incorrect MTU in broadcast routes 2025-08-20 18:36:04 +02:00
ipv6 ipv6: mcast: Check inet6_dev->dead under idev->mc_lock in __ipv6_dev_mc_inc(). 2025-08-20 18:36:07 +02:00
iucv
kcm net: kcm: Fix race condition in kcm_unattach() 2025-08-20 18:35:49 +02:00
key
l2tp
l3mdev
lapb
llc
mac80211 wifi: mac80211: update radar_required in channel context after channel switch 2025-08-20 18:36:11 +02:00
mac802154
mctp net: mctp: Prevent duplicate binds 2025-08-20 18:36:04 +02:00
mpls mpls: Use rcu_dereference_rtnl() in mpls_route_input_rcu(). 2025-06-27 11:13:39 +01:00
mptcp mptcp: reset fallback status gracefully at disconnect() time 2025-07-24 08:58:26 +02:00
ncsi net: ncsi: Fix buffer overflow in fetching version id 2025-08-20 18:36:14 +02:00
netfilter netfilter: nft_set_pipapo: prefer kvmalloc for scratch maps 2025-08-20 18:36:00 +02:00
netlabel
netlink netlink: avoid infinite retry looping in netlink_unicast() 2025-08-20 18:35:43 +02:00
netrom
nfc NFC: nci: uart: Set tty->disc_data only in success path 2025-06-27 11:13:04 +01:00
nsh
openvswitch
packet net/packet: fix a race in packet_set_ring() and packet_notifier() 2025-08-15 12:17:04 +02:00
phonet phonet/pep: Move call to pn_skb_get_dst_sockaddr() earlier in pep_sock_accept() 2025-07-24 08:58:26 +02:00
psample
qrtr
rds
rfkill
rose rose: fix dangling neighbour pointers in rose_rt_device_down() 2025-07-10 16:08:45 +02:00
rxrpc rxrpc: Fix to use conn aborts for conn-wide failures 2025-07-24 08:58:40 +02:00
sched net/sched: ets: use old 'nbands' while purging unused classes 2025-08-20 18:36:32 +02:00
sctp sctp: linearize cloned gso packets in sctp_rcv 2025-08-20 18:35:48 +02:00
shaper
smc smc: Fix various oops due to inet_sock type confusion. 2025-07-24 08:58:35 +02:00
strparser
sunrpc sunrpc: fix handling of server side tls alerts 2025-08-15 12:17:03 +02:00
switchdev
tipc tipc: Fix use-after-free in tipc_conn_close(). 2025-07-17 18:43:40 +02:00
tls tls: handle data disappearing from under the TLS ULP 2025-08-20 18:35:49 +02:00
unix af_unix: Don't set -ECONNRESET for consumed OOB skb. 2025-07-06 11:04:15 +02:00
vmw_vsock vsock/virtio: Resize receive buffers so that each SKB fits in a 4K page 2025-08-20 18:36:15 +02:00
wireless wifi: cfg80211: reject HTC bit for management frames 2025-08-20 18:36:02 +02:00
x25
xdp
xfrm xfrm: Duplicate SPI Handling 2025-08-20 18:36:09 +02:00
compat.c
devres.c
Kconfig
Kconfig.debug
Makefile
socket.c
sysctl_net.c