Eric Dumazet
12d94a8049
ipv6: fix NULL dereference in ip6_route_dev_notify()
Based on a syzkaller report [1], I found that a per cpu allocation
failure in snmp6_alloc_dev() would then lead to NULL dereference in
ip6_route_dev_notify().
It seems this is a very old bug, thus no Fixes tag in this submission.
Let's add in6_dev_put_clear() helper, as we will probably use
it elsewhere (once available/present in net-next)
[1]
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 17294 Comm: syz-executor6 Not tainted 4.13.0-rc2+ #10
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
task: ffff88019f456680 task.stack: ffff8801c6e58000
RIP: 0010:__read_once_size include/linux/compiler.h:250 [inline]
RIP: 0010:atomic_read arch/x86/include/asm/atomic.h:26 [inline]
RIP: 0010:refcount_sub_and_test+0x7d/0x1b0 lib/refcount.c:178
RSP: 0018:ffff8801c6e5f1b0 EFLAGS: 00010202
RAX: 0000000000000037 RBX: dffffc0000000000 RCX: ffffc90005d25000
RDX: ffff8801c6e5f218 RSI: ffffffff82342bbf RDI: 0000000000000001
RBP: ffff8801c6e5f240 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 1ffff10038dcbe37
R13: 0000000000000006 R14: 0000000000000001 R15: 00000000000001b8
FS: 00007f21e0429700(0000) GS:ffff8801dc100000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001ddbc22000 CR3: 00000001d632b000 CR4: 00000000001426e0
DR0: 0000000020000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600
Call Trace:
refcount_dec_and_test+0x1a/0x20 lib/refcount.c:211
in6_dev_put include/net/addrconf.h:335 [inline]
ip6_route_dev_notify+0x1c9/0x4a0 net/ipv6/route.c:3732
notifier_call_chain+0x136/0x2c0 kernel/notifier.c:93
__raw_notifier_call_chain kernel/notifier.c:394 [inline]
raw_notifier_call_chain+0x2d/0x40 kernel/notifier.c:401
call_netdevice_notifiers_info+0x51/0x90 net/core/dev.c:1678
call_netdevice_notifiers net/core/dev.c:1694 [inline]
rollback_registered_many+0x91c/0xe80 net/core/dev.c:7107
rollback_registered+0x1be/0x3c0 net/core/dev.c:7149
register_netdevice+0xbcd/0xee0 net/core/dev.c:7587
register_netdev+0x1a/0x30 net/core/dev.c:7669
loopback_net_init+0x76/0x160 drivers/net/loopback.c:214
ops_init+0x10a/0x570 net/core/net_namespace.c:118
setup_net+0x313/0x710 net/core/net_namespace.c:294
copy_net_ns+0x27c/0x580 net/core/net_namespace.c:418
create_new_namespaces+0x425/0x880 kernel/nsproxy.c:107
unshare_nsproxy_namespaces+0xae/0x1e0 kernel/nsproxy.c:206
SYSC_unshare kernel/fork.c:2347 [inline]
SyS_unshare+0x653/0xfa0 kernel/fork.c:2297
entry_SYSCALL_64_fastpath+0x1f/0xbe
RIP: 0033:0x4512c9
RSP: 002b:00007f21e0428c08 EFLAGS: 00000216 ORIG_RAX: 0000000000000110
RAX: ffffffffffffffda RBX: 0000000000718150 RCX: 00000000004512c9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000062020200
RBP: 0000000000000086 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000216 R12: 00000000004b973d
R13: 00000000ffffffff R14: 000000002001d000 R15: 00000000000002dd
Code: 50 2b 34 82 c7 00 f1 f1 f1 f1 c7 40 04 04 f2 f2 f2 c7 40 08 f3 f3
f3 f3 e8 a1 43 39 ff 4c 89 f8 48 8b 95 70 ff ff ff 48 c1 e8 03 <0f> b6
0c 18 4c 89 f8 83 e0 07 83 c0 03 38 c8 7c 08 84 c9 0f 85
RIP: __read_once_size include/linux/compiler.h:250 [inline] RSP:
ffff8801c6e5f1b0
RIP: atomic_read arch/x86/include/asm/atomic.h:26 [inline] RSP:
ffff8801c6e5f1b0
RIP: refcount_sub_and_test+0x7d/0x1b0 lib/refcount.c:178 RSP:
ffff8801c6e5f1b0
---[ end trace e441d046c6410d31 ]---
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-08-15 17:06:34 -07:00
..
2017-07-11 06:08:58 -04:00
2017-05-18 13:52:49 +02:00
2015-02-20 17:35:14 -05:00
2017-03-09 17:01:09 -08:00
2015-09-21 16:03:04 -07:00
2017-07-01 07:39:07 -07:00
2017-06-08 10:53:29 -04:00
2017-04-05 10:15:20 +02:00
2016-02-11 03:54:14 -05:00
2017-07-27 00:03:12 -07:00
2017-06-06 12:45:23 -04:00
2017-04-12 22:02:36 +02:00
2017-05-17 15:22:13 -04:00
2017-08-15 17:06:34 -07:00
2015-09-17 13:20:05 +02:00
2017-06-07 17:15:46 +01:00
2017-07-19 08:55:18 -07:00
2017-04-24 12:35:56 -04:00
2014-09-18 10:54:36 +02:00
2017-07-01 07:39:07 -07:00
2017-07-04 22:35:19 +01:00
2016-02-09 04:45:49 -05:00
2014-11-10 13:27:49 -05:00
2017-05-27 18:51:41 -04:00
2017-08-11 14:21:42 -07:00
2017-08-11 14:59:24 -07:00
2017-07-04 22:35:16 +01:00
2017-06-13 11:04:37 +02:00
2016-07-08 12:20:57 +02:00
2017-01-20 12:12:13 -05:00
2017-07-04 01:29:04 -07:00
2016-04-19 20:09:25 -04:00
2016-04-25 16:44:27 -04:00
2016-06-25 12:19:35 -04:00
2016-04-25 16:44:27 -04:00
2016-06-09 23:41:03 -07:00
2015-03-06 21:50:02 -05:00
2017-04-22 20:26:37 +03:00
2017-07-04 22:35:15 +01:00
2015-09-17 17:18:37 -07:00
2017-06-13 16:35:03 -04:00
2016-02-16 20:21:48 -05:00
2017-06-25 11:42:01 -04:00
2017-02-07 13:07:46 -05:00
2017-06-17 22:54:01 -04:00
2017-04-14 10:06:42 +02:00
2015-09-23 15:33:15 -07:00
2017-07-01 07:39:09 -07:00
2017-06-04 18:12:23 -04:00
2017-04-03 19:04:48 -07:00
2017-04-03 19:04:48 -07:00
2016-05-20 18:03:16 -04:00
2016-09-30 13:29:21 +02:00
2016-09-30 13:29:21 +02:00
2016-12-05 15:21:59 -05:00
2017-06-05 10:54:55 -04:00
2016-06-17 20:23:32 -07:00
2016-08-18 01:17:32 -04:00
2017-02-08 14:38:18 -05:00
2016-07-25 17:55:43 -07:00
2014-11-05 16:30:03 -05:00
2016-03-14 12:19:46 -04:00
2016-04-27 22:48:25 -04:00
2017-01-25 16:00:33 +01:00
2016-01-04 20:40:41 +01:00
2017-07-04 01:29:04 -07:00
2017-02-03 15:16:45 -05:00
2015-12-15 23:25:20 -05:00
2017-01-18 13:04:28 -05:00
2016-04-04 22:11:20 -04:00
2017-03-09 18:23:27 -08:00
2017-06-15 12:12:40 -04:00
2016-08-13 15:08:00 -07:00
2017-07-06 08:59:41 -07:00
2017-07-03 03:29:14 -07:00
2017-01-25 14:04:38 -05:00
2016-12-29 11:38:31 -05:00
2017-07-01 07:39:07 -07:00
2016-03-13 23:55:13 -04:00
2017-06-17 22:54:01 -04:00
2017-07-06 10:48:01 +01:00
2017-04-21 13:21:30 -04:00
2017-07-04 01:29:04 -07:00
2017-04-21 13:21:31 -04:00
2017-04-28 12:00:10 +02:00
2017-04-13 13:19:48 -04:00
2017-07-04 01:29:03 -07:00
2017-07-04 22:35:17 +01:00
2017-01-13 09:38:42 +01:00
2016-08-17 19:36:23 -04:00
2016-10-13 12:05:26 -04:00
2017-07-04 22:35:16 +01:00
2014-10-14 02:18:27 +02:00
2014-12-10 15:21:24 -05:00
2015-05-11 10:50:17 -04:00
2014-12-10 15:21:24 -05:00
2017-07-04 22:35:15 +01:00
2017-05-30 11:55:32 -04:00
2017-08-09 09:49:42 +03:00
2016-07-08 13:23:12 +02:00
2014-09-22 16:23:15 -04:00
2017-04-01 20:21:44 -07:00
2016-10-03 02:00:22 -04:00
2016-10-04 02:11:51 -04:00
2017-07-01 07:39:07 -07:00
2017-07-19 08:55:18 -07:00
2017-07-19 08:55:18 -07:00
2016-07-05 09:06:29 -07:00
2017-07-01 07:39:09 -07:00
2017-07-13 09:26:27 -07:00
2015-12-08 22:02:33 -05:00
2017-07-04 22:35:17 +01:00
2016-07-08 12:20:57 +02:00
2016-03-23 22:09:58 -04:00
2017-05-31 17:58:13 -04:00
2017-05-17 15:22:13 -04:00
2016-08-15 10:55:53 -07:00
2017-03-24 13:17:07 -07:00
2017-01-24 13:44:28 -05:00
2016-10-23 19:35:24 -04:00
2016-10-23 19:35:24 -04:00
2016-12-25 17:21:22 +01:00
2014-12-17 11:49:55 +01:00
2017-07-01 07:39:08 -07:00
2017-06-17 22:54:00 -04:00
2017-06-26 23:13:22 -04:00
2017-07-04 22:35:16 +01:00
2017-03-02 08:42:31 +01:00
2017-06-08 10:53:29 -04:00
2016-11-09 20:40:06 -05:00
2016-11-09 20:40:06 -05:00
2017-01-09 16:07:41 -05:00
2016-04-28 11:49:45 -04:00
2016-01-19 14:44:23 -05:00
2017-07-19 08:55:18 -07:00
2016-08-28 23:32:41 -04:00
2017-07-01 08:51:32 -07:00
2015-03-12 22:58:12 -04:00
2017-08-03 15:38:30 -07:00
2015-07-09 15:12:20 -07:00
2017-06-15 12:12:40 -04:00
2016-05-03 16:08:14 -04:00
2015-10-26 22:24:22 -07:00
2016-06-17 20:23:32 -07:00
2017-08-14 22:26:51 -07:00
2017-05-16 15:41:29 -04:00
2017-07-04 22:35:15 +01:00
2017-06-14 13:52:44 +02:00
2014-09-05 17:35:28 -07:00
2017-07-04 22:35:18 +01:00
2017-07-04 22:35:18 +01:00