linux-stable/net
Wander Lairson Costa 07ea878684 drop_monitor: replace spin_lock by raw_spin_lock
[ Upstream commit f1e197a665 ]

trace_drop_common() is called with preemption disabled, and it acquires
a spin_lock. This is problematic for RT kernels because spin_locks are
sleeping locks in this configuration, which causes the following splat:

BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 449, name: rcuc/47
preempt_count: 1, expected: 0
RCU nest depth: 2, expected: 2
5 locks held by rcuc/47/449:
 #0: ff1100086ec30a60 ((softirq_ctrl.lock)){+.+.}-{2:2}, at: __local_bh_disable_ip+0x105/0x210
 #1: ffffffffb394a280 (rcu_read_lock){....}-{1:2}, at: rt_spin_lock+0xbf/0x130
 #2: ffffffffb394a280 (rcu_read_lock){....}-{1:2}, at: __local_bh_disable_ip+0x11c/0x210
 #3: ffffffffb394a160 (rcu_callback){....}-{0:0}, at: rcu_do_batch+0x360/0xc70
 #4: ff1100086ee07520 (&data->lock){+.+.}-{2:2}, at: trace_drop_common.constprop.0+0xb5/0x290
irq event stamp: 139909
hardirqs last  enabled at (139908): [<ffffffffb1df2b33>] _raw_spin_unlock_irqrestore+0x63/0x80
hardirqs last disabled at (139909): [<ffffffffb19bd03d>] trace_drop_common.constprop.0+0x26d/0x290
softirqs last  enabled at (139892): [<ffffffffb07a1083>] __local_bh_enable_ip+0x103/0x170
softirqs last disabled at (139898): [<ffffffffb0909b33>] rcu_cpu_kthread+0x93/0x1f0
Preemption disabled at:
[<ffffffffb1de786b>] rt_mutex_slowunlock+0xab/0x2e0
CPU: 47 PID: 449 Comm: rcuc/47 Not tainted 6.9.0-rc2-rt1+ #7
Hardware name: Dell Inc. PowerEdge R650/0Y2G81, BIOS 1.6.5 04/15/2022
Call Trace:
 <TASK>
 dump_stack_lvl+0x8c/0xd0
 dump_stack+0x14/0x20
 __might_resched+0x21e/0x2f0
 rt_spin_lock+0x5e/0x130
 ? trace_drop_common.constprop.0+0xb5/0x290
 ? skb_queue_purge_reason.part.0+0x1bf/0x230
 trace_drop_common.constprop.0+0xb5/0x290
 ? preempt_count_sub+0x1c/0xd0
 ? _raw_spin_unlock_irqrestore+0x4a/0x80
 ? __pfx_trace_drop_common.constprop.0+0x10/0x10
 ? rt_mutex_slowunlock+0x26a/0x2e0
 ? skb_queue_purge_reason.part.0+0x1bf/0x230
 ? __pfx_rt_mutex_slowunlock+0x10/0x10
 ? skb_queue_purge_reason.part.0+0x1bf/0x230
 trace_kfree_skb_hit+0x15/0x20
 trace_kfree_skb+0xe9/0x150
 kfree_skb_reason+0x7b/0x110
 skb_queue_purge_reason.part.0+0x1bf/0x230
 ? __pfx_skb_queue_purge_reason.part.0+0x10/0x10
 ? mark_lock.part.0+0x8a/0x520
...

trace_drop_common() also disables interrupts, but this is a minor issue
because we could easily replace it with a local_lock.

Replace the spin_lock with raw_spin_lock to avoid sleeping in atomic
context.

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Reported-by: Hu Chunyu <chuhu@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-06-27 13:52:13 +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
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
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
kcm
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
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: initialize noop_qdisc owner 2024-06-21 14:40:22 +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
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
sysctl_net.c