linux-stable/net
Kuniyuki Iwashima ba2044cfe2 netlink: Add __sock_i_ino() for __netlink_diag_dump().
[ Upstream commit 25a9c8a443 ]

syzbot reported a warning in __local_bh_enable_ip(). [0]

Commit 8d61f926d4 ("netlink: fix potential deadlock in
netlink_set_err()") converted read_lock(&nl_table_lock) to
read_lock_irqsave() in __netlink_diag_dump() to prevent a deadlock.

However, __netlink_diag_dump() calls sock_i_ino() that uses
read_lock_bh() and read_unlock_bh().  If CONFIG_TRACE_IRQFLAGS=y,
read_unlock_bh() finally enables IRQ even though it should stay
disabled until the following read_unlock_irqrestore().

Using read_lock() in sock_i_ino() would trigger a lockdep splat
in another place that was fixed in commit f064af1e50 ("net: fix
a lockdep splat"), so let's add __sock_i_ino() that would be safe
to use under BH disabled.

[0]:
WARNING: CPU: 0 PID: 5012 at kernel/softirq.c:376 __local_bh_enable_ip+0xbe/0x130 kernel/softirq.c:376
Modules linked in:
CPU: 0 PID: 5012 Comm: syz-executor487 Not tainted 6.4.0-rc7-syzkaller-00202-g6f68fc395f49 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
RIP: 0010:__local_bh_enable_ip+0xbe/0x130 kernel/softirq.c:376
Code: 45 bf 01 00 00 00 e8 91 5b 0a 00 e8 3c 15 3d 00 fb 65 8b 05 ec e9 b5 7e 85 c0 74 58 5b 5d c3 65 8b 05 b2 b6 b4 7e 85 c0 75 a2 <0f> 0b eb 9e e8 89 15 3d 00 eb 9f 48 89 ef e8 6f 49 18 00 eb a8 0f
RSP: 0018:ffffc90003a1f3d0 EFLAGS: 00010046
RAX: 0000000000000000 RBX: 0000000000000201 RCX: 1ffffffff1cf5996
RDX: 0000000000000000 RSI: 0000000000000201 RDI: ffffffff8805c6f3
RBP: ffffffff8805c6f3 R08: 0000000000000001 R09: ffff8880152b03a3
R10: ffffed1002a56074 R11: 0000000000000005 R12: 00000000000073e4
R13: dffffc0000000000 R14: 0000000000000002 R15: 0000000000000000
FS:  0000555556726300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000045ad50 CR3: 000000007c646000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 sock_i_ino+0x83/0xa0 net/core/sock.c:2559
 __netlink_diag_dump+0x45c/0x790 net/netlink/diag.c:171
 netlink_diag_dump+0xd6/0x230 net/netlink/diag.c:207
 netlink_dump+0x570/0xc50 net/netlink/af_netlink.c:2269
 __netlink_dump_start+0x64b/0x910 net/netlink/af_netlink.c:2374
 netlink_dump_start include/linux/netlink.h:329 [inline]
 netlink_diag_handler_dump+0x1ae/0x250 net/netlink/diag.c:238
 __sock_diag_cmd net/core/sock_diag.c:238 [inline]
 sock_diag_rcv_msg+0x31e/0x440 net/core/sock_diag.c:269
 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2547
 sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:280
 netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline]
 netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1365
 netlink_sendmsg+0x925/0xe30 net/netlink/af_netlink.c:1914
 sock_sendmsg_nosec net/socket.c:724 [inline]
 sock_sendmsg+0xde/0x190 net/socket.c:747
 ____sys_sendmsg+0x71c/0x900 net/socket.c:2503
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2557
 __sys_sendmsg+0xf7/0x1c0 net/socket.c:2586
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f5303aaabb9
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc7506e548 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f5303aaabb9
RDX: 0000000000000000 RSI: 0000000020000180 RDI: 0000000000000003
RBP: 00007f5303a6ed60 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5303a6edf0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>

Fixes: 8d61f926d4 ("netlink: fix potential deadlock in netlink_set_err()")
Reported-by: syzbot+5da61cf6a9bc1902d422@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=5da61cf6a9bc1902d422
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20230626164313.52528-1-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-07-11 19:39:32 +02:00
..
6lowpan
9p 9p/xen : Fix use after free bug in xen_9pfs_front_remove due to race condition 2023-04-02 01:00:31 +00:00
802
8021q vlan: fix a potential uninit-value in vlan_dev_hard_start_xmit() 2023-05-24 17:30:18 +01:00
appletalk
atm atm: hide unused procfs functions 2023-06-09 10:48:09 +02:00
ax25
batman-adv batman-adv: Broken sync while rescheduling delayed work 2023-06-14 11:16:52 +02:00
bluetooth Bluetooth: Fix UAF in hci_conn_hash_flush again 2023-06-14 11:17:05 +02:00
bpf
bpfilter
bridge bridge: always declare tunnel functions 2023-05-24 17:30:19 +01:00
caif
can can: isotp: isotp_sendmsg(): fix return error fix on TX path 2023-07-01 13:14:44 +02:00
ceph
core netlink: Add __sock_i_ino() for __netlink_diag_dump(). 2023-07-11 19:39:32 +02:00
dcb
dccp netfilter: keep conntrack reference until IPsecv6 policy checks are done 2023-05-11 23:17:13 +09:00
devlink devlink: Fix crash with CONFIG_NET_NS=n 2023-05-24 17:30:18 +01:00
dns_resolver
dsa net: dsa: avoid suspicious RCU usage for synced VLAN-aware MAC addresses 2023-07-11 19:39:32 +02:00
ethernet
ethtool ethtool: Fix uninitialized number of lanes 2023-05-17 14:01:45 +02:00
hsr
ieee802154
ife
ipv4 xfrm: Linearize the skb after offloading if needed. 2023-06-28 11:14:12 +02:00
ipv6 xfrm: Linearize the skb after offloading if needed. 2023-06-28 11:14:12 +02:00
iucv
kcm
key af_key: Reject optional tunnel/BEET mode templates in outbound policies 2023-05-24 17:30:13 +01:00
l2tp l2tp: generate correct module alias strings 2023-03-31 09:25:12 +01:00
l3mdev
lapb
llc net: deal with most data-races in sk_wait_event() 2023-05-24 17:29:59 +01:00
mac80211 wifi: mac80211: Remove "Missing iftype sband data/EHT cap" spam 2023-07-11 19:39:30 +02:00
mac802154
mctp
mpls
mptcp mptcp: ensure listener is unhashed before updating the sk status 2023-06-28 11:14:07 +02:00
ncsi net/ncsi: clear Tx enable mode when handling a Config required AEN 2023-05-17 14:01:39 +02:00
netfilter netfilter: nf_conntrack_sip: fix the ct_sip_parse_numerical_param() return value. 2023-07-11 19:39:32 +02:00
netlabel
netlink netlink: Add __sock_i_ino() for __netlink_diag_dump(). 2023-07-11 19:39:32 +02:00
netrom netrom: fix info-leak in nr_write_internal() 2023-06-09 10:47:51 +02:00
nfc net: nfc: Fix use-after-free caused by nfc_llcp_find_local 2023-07-11 19:39:31 +02:00
nsh net: nsh: Use correct mac_offset to unwind gso skb in nsh_gso_segment() 2023-05-24 17:30:16 +01:00
openvswitch net: openvswitch: fix upcall counter access before allocation 2023-06-14 11:16:50 +02:00
packet af_packet: do not use READ_ONCE() in packet_bind() 2023-06-09 10:47:52 +02:00
phonet
psample
qrtr net: qrtr: Fix an uninit variable access bug in qrtr_tx_resume() 2023-04-13 09:35:30 +02:00
rds
rfkill
rose
rxrpc rxrpc: Truncate UTS_RELEASE for rxrpc version 2023-06-09 10:47:53 +02:00
sched net: sched: wrap tc_skip_wrapper with CONFIG_RETPOLINE 2023-06-28 11:14:22 +02:00
sctp sctp: add bpf_bypass_getsockopt proto callback 2023-07-11 19:39:27 +02:00
smc net/smc: Avoid to access invalid RMBs' MRs in SMCRv1 ADD LINK CONT 2023-06-14 11:16:44 +02:00
strparser
sunrpc svcrdma: Prevent page release when nothing was received 2023-07-11 19:39:23 +02:00
switchdev
tipc net: tipc: resize nlattr array to correct size 2023-06-21 16:02:18 +02:00
tls tls: improve lockless access safety of tls_err_abort() 2023-06-09 10:47:51 +02:00
unix bpf, sockmap: Pass skb ownership through read_skb 2023-06-05 09:29:39 +02:00
vmw_vsock vsock: avoid to close connected socket after the timeout 2023-05-24 17:30:14 +01:00
wireless wifi: cfg80211: fix regulatory disconnect with OCB/NAN 2023-07-11 19:39:30 +02:00
x25
xdp xsk: Fix unaligned descriptor validation 2023-05-11 23:17:16 +09:00
xfrm xfrm: add missed call to delete offloaded policies 2023-06-28 11:14:11 +02:00
Kconfig
Kconfig.debug
Makefile
compat.c
devres.c
socket.c net: annotate sk->sk_err write from do_recvmmsg() 2023-05-24 17:29:59 +01:00
sysctl_net.c