syzbot


stack segment fault in dev_hash_map_redirect

Status: fixed on 2024/08/14 03:44
Subsystems: bpf net
[Documentation on labels]
Reported-by: syzbot+c1e04a422bbc0f0f2921@syzkaller.appspotmail.com
Fix commit: fecef4cd42c6 tun: Assign missing bpf_net_context.
First crash: 167d, last: 156d
Cause bisection: introduced by (bisect log) :
commit 401cb7dae8130fd34eb84648e02ab4c506df7d5e
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu Jun 20 13:22:04 2024 +0000

  net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.

Crash: BUG: unable to handle kernel NULL pointer dereference in dev_hash_map_redirect (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[PATCH net-net] tun: Assign missing bpf_net_context. 18 (18) 2024/09/16 10:19
[syzbot] [bpf?] [net?] stack segment fault in dev_hash_map_redirect 0 (2) 2024/07/06 05:08

Sample crash report:
Oops: stack segment: 0000 [#1] PREEMPT SMP KASAN PTI
CPU: 0 UID: 0 PID: 5094 Comm: syz-executor316 Not tainted 6.10.0-rc6-next-20240703-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
RIP: 0010:bpf_net_ctx_get_ri include/linux/filter.h:788 [inline]
RIP: 0010:__bpf_xdp_redirect_map include/linux/filter.h:1699 [inline]
RIP: 0010:dev_hash_map_redirect+0x64/0x620 kernel/bpf/devmap.c:1022
Code: 00 48 89 d8 48 c1 e8 03 42 80 3c 38 00 74 08 48 89 df e8 9f 9c 3d 00 48 8b 03 48 89 44 24 08 48 8d 58 38 48 89 dd 48 c1 ed 03 <42> 0f b6 44 3d 00 84 c0 0f 85 f5 03 00 00 44 8b 33 44 89 f6 83 e6
RSP: 0018:ffffc9000356f958 EFLAGS: 00010202
RAX: 0000000000000000 RBX: 0000000000000038 RCX: ffff8880276e9e00
RDX: 0000000000000000 RSI: 000000000356f9b0 RDI: ffff88802f22f000
RBP: 0000000000000007 R08: 0000000000000007 R09: ffffffff81b5ee2f
R10: 0000000000000004 R11: ffff8880276e9e00 R12: 0000000000000008
R13: 000000000356f9b0 R14: 0000000000000000 R15: dffffc0000000000
FS:  000055557ccb9380(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000021d5ab98 CR3: 0000000022250000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 bpf_prog_ec9efaa32d58ce69+0x56/0x5a
 __bpf_prog_run include/linux/filter.h:691 [inline]
 bpf_prog_run_xdp include/net/xdp.h:514 [inline]
 tun_build_skb drivers/net/tun.c:1711 [inline]
 tun_get_user+0x3321/0x4560 drivers/net/tun.c:1819
 tun_chr_write_iter+0x113/0x1f0 drivers/net/tun.c:2048
 new_sync_write fs/read_write.c:497 [inline]
 vfs_write+0xa72/0xc90 fs/read_write.c:590
 ksys_write+0x1a0/0x2c0 fs/read_write.c:643
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fbd788a7f10
Code: 40 00 48 c7 c2 b8 ff ff ff f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 80 3d b1 e1 07 00 00 74 17 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 58 c3 0f 1f 80 00 00 00 00 48 83 ec 28 48 89
RSP: 002b:00007ffde33a9838 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fbd788a7f10
RDX: 000000000000004e RSI: 0000000020000540 RDI: 00000000000000c8
RBP: 0000000000000000 R08: 00007ffde33a9968 R09: 00007ffde33a9968
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:bpf_net_ctx_get_ri include/linux/filter.h:788 [inline]
RIP: 0010:__bpf_xdp_redirect_map include/linux/filter.h:1699 [inline]
RIP: 0010:dev_hash_map_redirect+0x64/0x620 kernel/bpf/devmap.c:1022
Code: 00 48 89 d8 48 c1 e8 03 42 80 3c 38 00 74 08 48 89 df e8 9f 9c 3d 00 48 8b 03 48 89 44 24 08 48 8d 58 38 48 89 dd 48 c1 ed 03 <42> 0f b6 44 3d 00 84 c0 0f 85 f5 03 00 00 44 8b 33 44 89 f6 83 e6
RSP: 0018:ffffc9000356f958 EFLAGS: 00010202
RAX: 0000000000000000 RBX: 0000000000000038 RCX: ffff8880276e9e00
RDX: 0000000000000000 RSI: 000000000356f9b0 RDI: ffff88802f22f000
RBP: 0000000000000007 R08: 0000000000000007 R09: ffffffff81b5ee2f
R10: 0000000000000004 R11: ffff8880276e9e00 R12: 0000000000000008
R13: 000000000356f9b0 R14: 0000000000000000 R15: dffffc0000000000
FS:  000055557ccb9380(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000021d5ab98 CR3: 0000000022250000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	00 48 89             	add    %cl,-0x77(%rax)
   3:	d8 48 c1             	fmuls  -0x3f(%rax)
   6:	e8 03 42 80 3c       	call   0x3c80420e
   b:	38 00                	cmp    %al,(%rax)
   d:	74 08                	je     0x17
   f:	48 89 df             	mov    %rbx,%rdi
  12:	e8 9f 9c 3d 00       	call   0x3d9cb6
  17:	48 8b 03             	mov    (%rbx),%rax
  1a:	48 89 44 24 08       	mov    %rax,0x8(%rsp)
  1f:	48 8d 58 38          	lea    0x38(%rax),%rbx
  23:	48 89 dd             	mov    %rbx,%rbp
  26:	48 c1 ed 03          	shr    $0x3,%rbp
* 2a:	42 0f b6 44 3d 00    	movzbl 0x0(%rbp,%r15,1),%eax <-- trapping instruction
  30:	84 c0                	test   %al,%al
  32:	0f 85 f5 03 00 00    	jne    0x42d
  38:	44 8b 33             	mov    (%rbx),%r14d
  3b:	44 89 f6             	mov    %r14d,%esi
  3e:	83                   	.byte 0x83
  3f:	e6                   	.byte 0xe6

Crashes (29):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/07/06 05:08 linux-next 0b58e108042b 2a40360c .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/09 07:18 linux-next 0b58e108042b bc23a442 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/09 07:18 linux-next 0b58e108042b bc23a442 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/08 19:36 linux-next 0b58e108042b cde64f7d .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/08 19:36 linux-next 0b58e108042b cde64f7d .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/06 17:13 linux-next 0b58e108042b bc4ebbb5 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/05 15:08 linux-next 0b58e108042b 2a40360c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/05 15:08 linux-next 0b58e108042b 2a40360c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/05 02:07 linux-next 0b58e108042b dc6bbff0 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/05 01:57 linux-next 0b58e108042b dc6bbff0 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/04 03:17 linux-next 0b58e108042b 409d975c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/04 03:17 linux-next 0b58e108042b 409d975c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/04 01:51 linux-next 0b58e108042b 409d975c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/04 01:51 linux-next 0b58e108042b 409d975c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/03 11:02 linux-next 0b58e108042b 1ecfa2d8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/03 11:02 linux-next 0b58e108042b 1ecfa2d8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/01 15:10 linux-next 74564adfd352 b294e901 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/01 15:07 linux-next 74564adfd352 b294e901 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/01 14:47 linux-next 74564adfd352 b294e901 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/01 14:41 linux-next 74564adfd352 b294e901 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/01 13:09 linux-next 74564adfd352 b294e901 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/07/01 10:06 linux-next 1eb586a9782c b294e901 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/06/28 19:48 linux-next 642a16ca7994 757f06b1 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/06/28 00:06 linux-next 642a16ca7994 b62c7d46 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/06/28 00:06 linux-next 642a16ca7994 b62c7d46 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/06/28 00:01 linux-next 642a16ca7994 b62c7d46 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/06/27 23:44 linux-next 642a16ca7994 b62c7d46 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/06/27 21:58 linux-next 642a16ca7994 b62c7d46 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
2024/06/27 21:58 linux-next 642a16ca7994 b62c7d46 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root stack segment fault in dev_hash_map_redirect
* Struck through repros no longer work on HEAD.