Eric Dumazet
cbfbfe3aee
tun: prevent negative ifindex
After commit 956db0a13b ("net: warn about attempts to register
negative ifindex") syzbot is able to trigger the following splat.
Negative ifindex are not supported.
WARNING: CPU: 1 PID: 6003 at net/core/dev.c:9596 dev_index_reserve+0x104/0x210
Modules linked in:
CPU: 1 PID: 6003 Comm: syz-executor926 Not tainted 6.6.0-rc4-syzkaller-g19af4a4ed414 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : dev_index_reserve+0x104/0x210
lr : dev_index_reserve+0x100/0x210
sp : ffff800096a878e0
x29: ffff800096a87930 x28: ffff0000d04380d0 x27: ffff0000d04380f8
x26: ffff0000d04380f0 x25: 1ffff00012d50f20 x24: 1ffff00012d50f1c
x23: dfff800000000000 x22: ffff8000929c21c0 x21: 00000000ffffffea
x20: ffff0000d04380e0 x19: ffff800096a87900 x18: ffff800096a874c0
x17: ffff800084df5008 x16: ffff80008051f9c4 x15: 0000000000000001
x14: 1fffe0001a087198 x13: 0000000000000000 x12: 0000000000000000
x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000
x8 : ffff0000d41c9bc0 x7 : 0000000000000000 x6 : 0000000000000000
x5 : ffff800091763d88 x4 : 0000000000000000 x3 : ffff800084e04748
x2 : 0000000000000001 x1 : 00000000fead71c7 x0 : 0000000000000000
Call trace:
dev_index_reserve+0x104/0x210
register_netdevice+0x598/0x1074 net/core/dev.c:10084
tun_set_iff+0x630/0xb0c drivers/net/tun.c:2850
__tun_chr_ioctl+0x788/0x2af8 drivers/net/tun.c:3118
tun_chr_ioctl+0x38/0x4c drivers/net/tun.c:3403
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:871 [inline]
__se_sys_ioctl fs/ioctl.c:857 [inline]
__arm64_sys_ioctl+0x14c/0x1c8 fs/ioctl.c:857
__invoke_syscall arch/arm64/kernel/syscall.c:37 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:51
el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:136
do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:155
el0_svc+0x58/0x16c arch/arm64/kernel/entry-common.c:678
el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:696
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:595
irq event stamp: 11348
hardirqs last enabled at (11347): [<ffff80008a716574>] __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:151 [inline]
hardirqs last enabled at (11347): [<ffff80008a716574>] _raw_spin_unlock_irqrestore+0x38/0x98 kernel/locking/spinlock.c:194
hardirqs last disabled at (11348): [<ffff80008a627820>] el1_dbg+0x24/0x80 arch/arm64/kernel/entry-common.c:436
softirqs last enabled at (11138): [<ffff8000887ca53c>] spin_unlock_bh include/linux/spinlock.h:396 [inline]
softirqs last enabled at (11138): [<ffff8000887ca53c>] release_sock+0x15c/0x1b0 net/core/sock.c:3531
softirqs last disabled at (11136): [<ffff8000887ca41c>] spin_lock_bh include/linux/spinlock.h:356 [inline]
softirqs last disabled at (11136): [<ffff8000887ca41c>] release_sock+0x3c/0x1b0 net/core/sock.c:3518
Fixes: fb7589a162 ("tun: Add ability to create tun device with given index")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20231016180851.3560092-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-10-17 17:44:51 -07:00
..
2023-09-27 07:40:43 +02:00
2023-10-06 07:46:25 -07:00
2023-08-22 15:50:57 +02:00
2023-09-01 09:53:54 -07:00
2023-10-10 14:42:22 +09:00
2023-08-30 13:34:34 -07:00
2023-10-03 11:57:37 -07:00
2023-10-06 15:43:19 -07:00
2023-10-13 20:03:04 -07:00
2023-09-13 10:24:53 +03:00
2023-09-01 09:08:59 -07:00
2023-09-13 11:44:20 -07:00
2023-09-12 10:56:05 -07:00
2023-09-04 13:15:57 -07:00
2023-09-12 15:49:20 +02:00
2023-09-04 13:47:59 -07:00
2023-08-29 20:51:40 +02:00
2023-08-31 12:43:10 -07:00
2023-08-29 11:23:29 -07:00
2023-09-22 14:31:04 -07:00
2023-08-24 16:20:30 -07:00
2023-10-04 10:29:55 +01:00
2023-08-30 13:34:34 -07:00
2023-08-30 19:23:00 -07:00
2023-09-28 21:23:00 +09:00
2023-09-30 18:41:37 -07:00
2023-08-22 15:51:33 +02:00
2023-10-05 08:41:56 +02:00
2023-10-06 12:48:06 +10:00
2023-10-06 16:09:14 +02:00
2023-08-28 13:31:06 -05:00
2023-09-04 11:26:29 -07:00
2023-09-18 11:52:18 -07:00
2023-08-18 16:42:26 +01:00
2023-09-27 21:32:06 +02:00
2023-09-06 01:21:47 +02:00
2023-08-28 16:35:01 -07:00
2023-09-01 09:53:54 -07:00
2023-10-05 20:01:47 +03:00
2023-09-06 09:24:25 -07:00
2023-08-30 19:53:39 -07:00
2023-09-25 16:10:36 +02:00
2023-10-10 11:14:07 -07:00
2023-08-20 14:29:37 +02:00
2023-09-19 15:16:23 +01:00
2023-08-31 12:43:10 -07:00
2023-09-05 10:11:01 -05:00
2023-10-10 10:47:35 -07:00
2023-10-05 11:34:29 +02:00
2023-10-05 11:03:20 -07:00
2023-09-25 10:48:19 +02:00
2023-09-01 09:38:00 -07:00
2023-09-07 21:59:04 +02:00
2023-08-28 13:36:24 -05:00
2023-10-17 17:44:51 -07:00
2023-08-30 18:32:24 -07:00
2023-08-22 12:38:19 -04:00
2023-08-30 20:52:08 -07:00
2023-09-14 16:20:31 -06:00
2023-08-23 16:34:02 +02:00
2023-10-02 11:34:23 -05:00
2023-08-18 10:55:49 +05:30
2023-08-31 21:42:42 +02:00
2023-09-01 09:38:00 -07:00
2023-10-06 09:11:13 -07:00
2023-09-29 16:24:59 +01:00
2023-10-06 10:59:52 +01:00
2023-10-12 09:10:40 +02:00
2023-10-06 15:09:40 +02:00
2023-10-05 00:28:52 +02:00
2023-08-17 19:38:35 +02:00
2023-09-20 19:37:15 +02:00
2023-09-06 22:21:22 +02:00
2023-10-02 07:19:22 +01:00
2023-09-07 18:05:58 -07:00
2023-09-26 17:26:08 +02:00
2023-09-04 15:12:26 -07:00
2023-08-30 19:53:39 -07:00
2023-09-04 15:08:52 -07:00
2023-09-07 16:07:35 -07:00
2023-10-10 11:51:41 +02:00
2023-08-28 13:36:24 -05:00
2023-10-10 14:42:22 +09:00
2023-10-12 11:52:23 -07:00
2023-09-03 10:20:57 -07:00
2023-09-27 17:06:36 +02:00
2023-10-02 10:02:53 +02:00
2023-09-27 10:55:29 -04:00
2023-10-12 11:52:23 -07:00
2023-09-18 13:13:05 +02:00
2023-08-22 14:22:35 +02:00
2023-09-18 10:12:11 +02:00
2023-09-05 06:10:24 -04:00
2023-08-22 13:41:55 +02:00
2023-09-11 13:52:16 +02:00
2023-09-04 10:43:44 -07:00
2023-09-22 12:48:04 -06:00
2023-10-04 08:26:48 +01:00
2023-09-21 10:33:49 +02:00
2023-08-24 16:20:18 -07:00
2023-09-03 18:10:24 -04:00
2023-09-13 10:48:42 +02:00
2023-09-06 09:19:12 -07:00
2023-10-09 09:21:16 +02:00
2023-08-21 13:27:44 +02:00
2023-09-08 11:24:34 -07:00
2023-09-13 11:09:21 +02:00