Eric Dumazet
032be5f19a
rxrpc: fix race condition in rxrpc_input_packet()
...
After commit 5271953cad ("rxrpc: Use the UDP encap_rcv hook"),
rxrpc_input_packet() is directly called from lockless UDP receive
path, under rcu_read_lock() protection.
It must therefore use RCU rules :
- udp_sk->sk_user_data can be cleared at any point in this function.
rcu_dereference_sk_user_data() is what we need here.
- Also, since sk_user_data might have been set in rxrpc_open_socket()
we must observe a proper RCU grace period before kfree(local) in
rxrpc_lookup_local()
v4: @local can be NULL in xrpc_lookup_local() as reported by kbuild test robot <lkp@intel.com>
and Julia Lawall <julia.lawall@lip6.fr>, thanks !
v3,v2 : addressed David Howells feedback, thanks !
syzbot reported :
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1 ] PREEMPT SMP KASAN
CPU: 0 PID: 19236 Comm: syz-executor703 Not tainted 5.1.0-rc6 #79
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__lock_acquire+0xbef/0x3fb0 kernel/locking/lockdep.c:3573
Code: 00 0f 85 a5 1f 00 00 48 81 c4 10 01 00 00 5b 41 5c 41 5d 41 5e 41 5f 5d c3 48 b8 00 00 00 00 00 fc ff df 4c 89 ea 48 c1 ea 03 <80> 3c 02 00 0f 85 4a 21 00 00 49 81 7d 00 20 54 9c 89 0f 84 cf f4
RSP: 0018:ffff88809d7aef58 EFLAGS: 00010002
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000026 RSI: 0000000000000000 RDI: 0000000000000001
RBP: ffff88809d7af090 R08: 0000000000000001 R09: 0000000000000001
R10: ffffed1015d05bc7 R11: ffff888089428600 R12: 0000000000000000
R13: 0000000000000130 R14: 0000000000000001 R15: 0000000000000001
FS: 00007f059044d700(0000) GS:ffff8880ae800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000004b6040 CR3: 00000000955ca000 CR4: 00000000001406f0
Call Trace:
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4211
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0x95/0xcd kernel/locking/spinlock.c:152
skb_queue_tail+0x26/0x150 net/core/skbuff.c:2972
rxrpc_reject_packet net/rxrpc/input.c:1126 [inline]
rxrpc_input_packet+0x4a0/0x5536 net/rxrpc/input.c:1414
udp_queue_rcv_one_skb+0xaf2/0x1780 net/ipv4/udp.c:2011
udp_queue_rcv_skb+0x128/0x730 net/ipv4/udp.c:2085
udp_unicast_rcv_skb.isra.0+0xb9/0x360 net/ipv4/udp.c:2245
__udp4_lib_rcv+0x701/0x2ca0 net/ipv4/udp.c:2301
udp_rcv+0x22/0x30 net/ipv4/udp.c:2482
ip_protocol_deliver_rcu+0x60/0x8f0 net/ipv4/ip_input.c:208
ip_local_deliver_finish+0x23b/0x390 net/ipv4/ip_input.c:234
NF_HOOK include/linux/netfilter.h:289 [inline]
NF_HOOK include/linux/netfilter.h:283 [inline]
ip_local_deliver+0x1e9/0x520 net/ipv4/ip_input.c:255
dst_input include/net/dst.h:450 [inline]
ip_rcv_finish+0x1e1/0x300 net/ipv4/ip_input.c:413
NF_HOOK include/linux/netfilter.h:289 [inline]
NF_HOOK include/linux/netfilter.h:283 [inline]
ip_rcv+0xe8/0x3f0 net/ipv4/ip_input.c:523
__netif_receive_skb_one_core+0x115/0x1a0 net/core/dev.c:4987
__netif_receive_skb+0x2c/0x1c0 net/core/dev.c:5099
netif_receive_skb_internal+0x117/0x660 net/core/dev.c:5202
napi_frags_finish net/core/dev.c:5769 [inline]
napi_gro_frags+0xade/0xd10 net/core/dev.c:5843
tun_get_user+0x2f24/0x3fb0 drivers/net/tun.c:1981
tun_chr_write_iter+0xbd/0x156 drivers/net/tun.c:2027
call_write_iter include/linux/fs.h:1866 [inline]
do_iter_readv_writev+0x5e1/0x8e0 fs/read_write.c:681
do_iter_write fs/read_write.c:957 [inline]
do_iter_write+0x184/0x610 fs/read_write.c:938
vfs_writev+0x1b3/0x2f0 fs/read_write.c:1002
do_writev+0x15e/0x370 fs/read_write.c:1037
__do_sys_writev fs/read_write.c:1110 [inline]
__se_sys_writev fs/read_write.c:1107 [inline]
__x64_sys_writev+0x75/0xb0 fs/read_write.c:1107
do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Fixes: 5271953cad ("rxrpc: Use the UDP encap_rcv hook")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-24 14:05:09 -07:00
arch
RISC-V Patches for 5.1-rc6
2019-04-16 10:46:37 -07:00
block
block: do not leak memory in bio_copy_user_iov()
2019-04-10 16:14:40 -06:00
certs
crypto
lib/lzo: separate lzo-rle from lzo
2019-03-07 18:32:03 -08:00
Documentation
Documentation: decnet: remove reference to CONFIG_DECNET_ROUTE_FWMARK
2019-04-21 11:25:11 -07:00
drivers
net: vrf: Fix operation not supported when set vrf mac
2019-04-24 11:45:04 -07:00
fs
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
2019-04-17 09:57:45 -07:00
include
net/ncsi: handle overflow when incrementing mac address
2019-04-23 21:15:15 -07:00
init
init/main: add checks for the return value of memblock_alloc*()
2019-03-12 10:04:02 -07:00
ipc
Merge branch 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2019-03-12 14:08:19 -07:00
kernel
Merge branch 'page-refs' (page ref overflow)
2019-04-14 15:09:40 -07:00
lib
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2019-04-09 16:20:59 -10:00
LICENSES
mm
Merge branch 'page-refs' (page ref overflow)
2019-04-14 15:09:40 -07:00
net
rxrpc: fix race condition in rxrpc_input_packet()
2019-04-24 14:05:09 -07:00
samples
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
2019-03-11 08:54:01 -07:00
scripts
fs: stream_open - opener for stream-like files so that read and write can run simultaneously without deadlock
2019-04-06 07:01:55 -10:00
security
apparmor: Restore Y/N in /sys for apparmor's "enabled"
2019-04-10 04:24:48 -07:00
sound
ASoC: Fixes for v5.1
2019-04-11 14:36:30 +02:00
tools
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
2019-04-22 21:23:55 -07:00
usr
virt
KVM: fix spectrev1 gadgets
2019-04-16 15:38:07 +02:00
.clang-format
clang-format: Update with the latest for_each macro list
2019-04-12 12:49:54 +02:00
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
Update Nicolas Pitre's email address
2019-04-02 18:12:44 -10:00
COPYING
CREDITS
Char/Misc driver patches for 5.1-rc1
2019-03-06 14:18:59 -08:00
Kbuild
Kbuild updates for v5.1
2019-03-10 17:48:21 -07:00
Kconfig
MAINTAINERS
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
2019-04-17 09:57:45 -07:00
Makefile
Linux 5.1-rc5
2019-04-14 15:17:41 -07:00
README