Eric Dumazet
7876df0500
net/packet: fix race in tpacket_snd()
...
[ Upstream commit 32d3182cd2cd29b2e7e04df7b0db350fbe11289f ]
packet_sendmsg() checks tx_ring.pg_vec to decide
if it must call tpacket_snd().
Problem is that the check is lockless, meaning another thread
can issue a concurrent setsockopt(PACKET_TX_RING ) to flip
tx_ring.pg_vec back to NULL.
Given that tpacket_snd() grabs pg_vec_lock mutex, we can
perform the check again to solve the race.
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: 1 PID: 11429 Comm: syz-executor394 Not tainted 5.3.0-rc4+ #101
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:packet_lookup_frame+0x8d/0x270 net/packet/af_packet.c:474
Code: c1 ee 03 f7 73 0c 80 3c 0e 00 0f 85 cb 01 00 00 48 8b 0b 89 c0 4c 8d 24 c1 48 b8 00 00 00 00 00 fc ff df 4c 89 e1 48 c1 e9 03 <80> 3c 01 00 0f 85 94 01 00 00 48 8d 7b 10 4d 8b 3c 24 48 b8 00 00
RSP: 0018:ffff88809f82f7b8 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: ffff8880a45c7030 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 1ffff110148b8e06 RDI: ffff8880a45c703c
RBP: ffff88809f82f7e8 R08: ffff888087aea200 R09: fffffbfff134ae50
R10: fffffbfff134ae4f R11: ffffffff89a5727f R12: 0000000000000000
R13: 0000000000000001 R14: ffff8880a45c6ac0 R15: 0000000000000000
FS: 00007fa04716f700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa04716edb8 CR3: 0000000091eb4000 CR4: 00000000001406e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
packet_current_frame net/packet/af_packet.c:487 [inline]
tpacket_snd net/packet/af_packet.c:2667 [inline]
packet_sendmsg+0x590/0x6250 net/packet/af_packet.c:2975
sock_sendmsg_nosec net/socket.c:637 [inline]
sock_sendmsg+0xd7/0x130 net/socket.c:657
___sys_sendmsg+0x3e2/0x920 net/socket.c:2311
__sys_sendmmsg+0x1bf/0x4d0 net/socket.c:2413
__do_sys_sendmmsg net/socket.c:2442 [inline]
__se_sys_sendmmsg net/socket.c:2439 [inline]
__x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2439
do_syscall_64+0xfd/0x6a0 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Fixes: 69e3c75f4d54 ("net: TX_RING and packet mmap")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-25 10:51:51 +02:00
..
2018-10-03 17:01:42 -07:00
2019-08-04 09:33:28 +02:00
2019-05-16 19:43:46 +02:00
2019-04-20 09:07:53 +02:00
2019-04-27 09:34:40 +02:00
2019-06-22 08:17:21 +02:00
2019-08-04 09:33:15 +02:00
2019-08-04 09:33:32 +02:00
2019-08-11 12:22:16 +02:00
2019-05-08 07:19:07 +02:00
2019-07-10 09:55:33 +02:00
2019-08-11 12:22:15 +02:00
2019-08-25 10:51:50 +02:00
2018-09-19 22:47:15 +02:00
2019-04-03 06:24:14 +02:00
2018-02-25 11:05:44 +01:00
2018-07-22 14:27:39 +02:00
2019-02-12 19:45:00 +01:00
2017-02-18 15:11:43 +01:00
2019-03-19 13:14:08 +01:00
2019-05-02 09:32:06 +02:00
2019-08-25 10:51:42 +02:00
2019-08-25 10:51:42 +02:00
2017-05-25 15:44:41 +02:00
2018-09-15 09:43:01 +02:00
2018-03-31 18:11:34 +02:00
2019-04-17 08:36:44 +02:00
2019-08-04 09:33:16 +02:00
2019-08-11 12:22:17 +02:00
2016-09-10 23:12:53 -07:00
2019-06-22 08:17:22 +02:00
2019-06-11 12:22:33 +02:00
2019-08-25 10:51:38 +02:00
2018-09-09 20:01:19 +02:00
2018-03-11 16:21:34 +01:00
2016-10-20 11:23:08 -04:00
2019-08-25 10:51:51 +02:00
2019-03-13 14:04:53 -07:00
2018-08-09 12:17:59 +02:00
2019-08-04 09:33:35 +02:00
2019-08-04 09:33:34 +02:00
2019-08-04 09:33:33 +02:00
2019-08-25 10:51:51 +02:00
2019-03-23 13:19:44 +01:00
2018-08-24 13:12:36 +02:00
2019-06-11 12:22:46 +02:00
2018-05-16 10:08:43 +02:00
2019-04-03 06:24:14 +02:00
2019-08-04 09:33:34 +02:00
2019-08-11 12:22:18 +02:00
2019-07-10 09:55:40 +02:00
2018-04-29 11:32:02 +02:00
2019-07-21 09:05:57 +02:00
2016-10-19 10:58:04 -04:00
2019-08-11 12:22:17 +02:00
2019-03-19 13:14:10 +01:00
2019-05-25 18:26:44 +02:00
2019-07-10 09:55:35 +02:00
2019-03-19 13:14:09 +01:00
2019-08-04 09:33:20 +02:00
2019-01-09 16:16:41 +01:00
2019-08-25 10:51:40 +02:00
2016-10-06 09:52:23 -07:00