linux-stable/net
Davide Caratti 79cb38ec95 net/sched: fix false lockdep warning on qdisc root lock
[ Upstream commit af0cb3fa3f ]

Xiumei and Christoph reported the following lockdep splat, complaining of
the qdisc root lock being taken twice:

 ============================================
 WARNING: possible recursive locking detected
 6.7.0-rc3+ #598 Not tainted
 --------------------------------------------
 swapper/2/0 is trying to acquire lock:
 ffff888177190110 (&sch->q.lock){+.-.}-{2:2}, at: __dev_queue_xmit+0x1560/0x2e70

 but task is already holding lock:
 ffff88811995a110 (&sch->q.lock){+.-.}-{2:2}, at: __dev_queue_xmit+0x1560/0x2e70

 other info that might help us debug this:
  Possible unsafe locking scenario:

        CPU0
        ----
   lock(&sch->q.lock);
   lock(&sch->q.lock);

  *** DEADLOCK ***

  May be due to missing lock nesting notation

 5 locks held by swapper/2/0:
  #0: ffff888135a09d98 ((&in_dev->mr_ifc_timer)){+.-.}-{0:0}, at: call_timer_fn+0x11a/0x510
  #1: ffffffffaaee5260 (rcu_read_lock){....}-{1:2}, at: ip_finish_output2+0x2c0/0x1ed0
  #2: ffffffffaaee5200 (rcu_read_lock_bh){....}-{1:2}, at: __dev_queue_xmit+0x209/0x2e70
  #3: ffff88811995a110 (&sch->q.lock){+.-.}-{2:2}, at: __dev_queue_xmit+0x1560/0x2e70
  #4: ffffffffaaee5200 (rcu_read_lock_bh){....}-{1:2}, at: __dev_queue_xmit+0x209/0x2e70

 stack backtrace:
 CPU: 2 PID: 0 Comm: swapper/2 Not tainted 6.7.0-rc3+ #598
 Hardware name: Red Hat KVM, BIOS 1.13.0-2.module+el8.3.0+7353+9de0a3cc 04/01/2014
 Call Trace:
  <IRQ>
  dump_stack_lvl+0x4a/0x80
  __lock_acquire+0xfdd/0x3150
  lock_acquire+0x1ca/0x540
  _raw_spin_lock+0x34/0x80
  __dev_queue_xmit+0x1560/0x2e70
  tcf_mirred_act+0x82e/0x1260 [act_mirred]
  tcf_action_exec+0x161/0x480
  tcf_classify+0x689/0x1170
  prio_enqueue+0x316/0x660 [sch_prio]
  dev_qdisc_enqueue+0x46/0x220
  __dev_queue_xmit+0x1615/0x2e70
  ip_finish_output2+0x1218/0x1ed0
  __ip_finish_output+0x8b3/0x1350
  ip_output+0x163/0x4e0
  igmp_ifc_timer_expire+0x44b/0x930
  call_timer_fn+0x1a2/0x510
  run_timer_softirq+0x54d/0x11a0
  __do_softirq+0x1b3/0x88f
  irq_exit_rcu+0x18f/0x1e0
  sysvec_apic_timer_interrupt+0x6f/0x90
  </IRQ>

This happens when TC does a mirred egress redirect from the root qdisc of
device A to the root qdisc of device B. As long as these two locks aren't
protecting the same qdisc, they can be acquired in chain: add a per-qdisc
lockdep key to silence false warnings.
This dynamic key should safely replace the static key we have in sch_htb:
it was added to allow enqueueing to the device "direct qdisc" while still
holding the qdisc root lock.

v2: don't use static keys anymore in HTB direct qdiscs (thanks Eric Dumazet)

CC: Maxim Mikityanskiy <maxim@isovalent.com>
CC: Xiumei Mu <xmu@redhat.com>
Reported-by: Christoph Paasch <cpaasch@apple.com>
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/451
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Link: https://lore.kernel.org/r/7dc06d6158f72053cf877a82e2a7a5bd23692faa.1713448007.git.dcaratti@redhat.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-06-27 13:52:14 +02:00
..
6lowpan
9p net/9p: fix uninit-value in p9_client_rpc() 2024-06-16 13:51:05 +02:00
802
8021q net: gro: fix udp bad offset in socket lookup by adding {inner_}network_offset to napi_gro_cb 2024-05-02 11:02:48 +02:00
appletalk appletalk: Improve handling of broadcast packets 2024-05-08 12:17:19 +01:00
atm inet: introduce dst_rtable() helper 2024-06-12 11:39:55 +02:00
ax25 ax25: Replace kfree() in ax25_dev_free() with ax25_dev_put() 2024-06-21 14:40:03 +02:00
batman-adv batman-adv: bypass empty buckets in batadv_purge_orig_ref() 2024-06-27 13:52:13 +02:00
bluetooth Bluetooth: fix connection setup in l2cap_connect 2024-06-21 14:40:22 +02:00
bpf bpf: Set run context for rawtp test_run callback 2024-06-21 14:40:05 +02:00
bridge net: bridge: mst: fix suspicious rcu usage in br_mst_set_state 2024-06-21 14:40:25 +02:00
caif
can
ceph
core drop_monitor: replace spin_lock by raw_spin_lock 2024-06-27 13:52:13 +02:00
dcb
dccp Kbuild updates for v6.9 2024-03-21 14:41:00 -07:00
devlink devlink: use kvzalloc() to allocate devlink instance resources 2024-06-27 13:52:12 +02:00
dns_resolver
dsa net: dsa: Leverage core stats allocator 2024-03-07 20:37:13 -08:00
ethernet netkit: Fix pkt_type override upon netkit pass verdict 2024-06-12 11:39:48 +02:00
ethtool net: ethtool: fix the error condition in ethtool_get_phy_stats_ethtool() 2024-06-21 14:40:10 +02:00
handshake
hsr hsr: Simplify code for announcing HSR nodes timer setup 2024-05-08 18:56:30 -07:00
ieee802154 Merge tag 'ieee802154-for-net-next-2024-03-07' of git://git.kernel.org/pub/scm/linux/kernel/git/wpan/wpan-next 2024-03-08 20:35:33 -08:00
ife
ipv4 tcp: use signed arithmetic in tcp_rtx_probe0_timed_out() 2024-06-21 14:40:23 +02:00
ipv6 net/ipv6: Fix the RT cache flush via sysctl using a previous delay 2024-06-21 14:40:25 +02:00
iucv more s390 updates for 6.9 merge window 2024-03-19 11:38:27 -07:00
kcm net: kcm: fix incorrect parameter validation in the kcm_getsockopt) function 2024-03-11 09:53:22 +00:00
key
l2tp inet: introduce dst_rtable() helper 2024-06-12 11:39:55 +02:00
l3mdev
lapb
llc
mac80211 wifi: mac80211: correctly parse Spatial Reuse Parameter Set element 2024-06-21 14:40:02 +02:00
mac802154
mctp
mpls inet: introduce dst_rtable() helper 2024-06-12 11:39:55 +02:00
mptcp mptcp: pm: update add_addr counters after connect 2024-06-21 14:40:30 +02:00
ncsi net/ncsi: Fix the multi thread manner of NCSI driver 2024-06-21 14:40:03 +02:00
netfilter netfilter: ipset: Fix race between namespace cleanup and gc in the list:set type 2024-06-21 14:40:23 +02:00
netlabel
netlink net/netlink: Add getsockopt support for NETLINK_LISTEN_ALL_NSID 2024-03-11 15:48:34 -07:00
netrom netrom: fix possible dead-lock in nr_rt_ioctl() 2024-05-30 09:45:02 +02:00
nfc nfc: nci: Fix handling of zero-length payload packets in nci_rx_work() 2024-06-12 11:39:43 +02:00
nsh nsh: Restore skb->{protocol,data,mac_header} for outer header in nsh_gso_segment(). 2024-04-26 12:20:01 +02:00
openvswitch openvswitch: Set the skbuff pkt_type for proper pmtud support. 2024-06-12 11:39:41 +02:00
packet af_packet: avoid a false positive warning in packet_setsockopt() 2024-06-27 13:52:13 +02:00
phonet phonet: fix rtm_phonet_notify() skb allocation 2024-05-06 18:30:00 -07:00
psample
qrtr net: qrtr: ns: Fix module refcnt 2024-05-30 09:45:02 +02:00
rds net/rds: fix possible cp null dereference 2024-03-29 12:04:09 -07:00
rfkill
rose
rxrpc rxrpc: Only transmit one ACK per jumbo packet received 2024-05-08 08:05:03 -07:00
sched net/sched: fix false lockdep warning on qdisc root lock 2024-06-27 13:52:14 +02:00
sctp inet: introduce dst_rtable() helper 2024-06-12 11:39:55 +02:00
smc net/smc: avoid overwriting when adjusting sock bufsizes 2024-06-21 14:40:05 +02:00
strparser
sunrpc SUNRPC: return proper error from gss_wrap_req_priv 2024-06-21 14:40:17 +02:00
switchdev
tipc inet: introduce dst_rtable() helper 2024-06-12 11:39:55 +02:00
tls tls: fix missing memory barrier in tls_init 2024-06-12 11:39:43 +02:00
unix af_unix: Read with MSG_PEEK loops if the first unread byte is OOB 2024-06-21 14:40:26 +02:00
vmw_vsock vsock/virtio: fix packet delivery to tap device 2024-04-02 18:00:24 -07:00
wireless wifi: cfg80211: validate HE operation element parsing 2024-06-21 14:40:31 +02:00
x25 net/x25: fix incorrect parameter validation in the x25_getsockopt() function 2024-03-11 09:53:22 +00:00
xdp Revert "xsk: Support redirect to any socket bound to the same umem" 2024-06-16 13:51:10 +02:00
xfrm net: fix __dst_negative_advice() race 2024-06-12 11:39:55 +02:00
compat.c
devres.c
Kconfig
Kconfig.debug
Makefile
socket.c net: remove {revc,send}msg_copy_msghdr() from exports 2024-03-14 16:48:53 -07:00
sysctl_net.c