syzbot


general protection fault in bpf_struct_ops_find_value

Status: fixed on 2024/04/10 03:59
Subsystems: bpf
[Documentation on labels]
Reported-by: syzbot+88f0aafe5f950d7489d7@syzkaller.appspotmail.com
Fix commit: e6be8cd5d3cf bpf: Fix error checks against bpf_get_btf_vmlinux().
First crash: 93d, last: 89d
Cause bisection: introduced by (bisect log) :
commit fcc2c1fb0651477c8ed78a3a293c175ccd70697a
Author: Kui-Feng Lee <thinker.li@gmail.com>
Date: Fri Jan 19 22:49:59 2024 +0000

  bpf: pass attached BTF to the bpf_struct_ops subsystem

Crash: BUG: unable to handle kernel NULL pointer dereference in btf_get (log)
Repro: C syz .config
  
Discussions (3)
Title Replies (including bot) Last reply
[PATCH bpf-next v2] bpf: Fix error checks against bpf_get_btf_vmlinux(). 2 (2) 2024/01/26 05:10
[PATCH bpf-next] bpf: Fix error checks against bpf_get_btf_vmlinux(). 3 (3) 2024/01/26 02:08
[syzbot] [bpf?] general protection fault in bpf_struct_ops_find_value 2 (3) 2024/01/25 18:17

Sample crash report:
general protection fault, probably for non-canonical address 0xdffffc0000000011: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000088-0x000000000000008f]
CPU: 0 PID: 5058 Comm: syz-executor257 Not tainted 6.7.0-syzkaller-12348-gd47b9f68d289 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
RIP: 0010:bpf_struct_ops_find_value+0x49/0x140 kernel/bpf/btf.c:8763
Code: 7d ea dd ff 45 85 e4 0f 84 d7 00 00 00 e8 ff ee dd ff 48 8d bb 88 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 dc 00 00 00 48 8b 9b 88 00 00 00 48 85 db 0f 84
RSP: 0018:ffffc90003bb7b20 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff81aa3283
RDX: 0000000000000011 RSI: ffffffff81aa3291 RDI: 0000000000000088
RBP: ffffc90003bb7dd0 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000000 R12: 0000000000000002
R13: 000000000000001a R14: ffffffff8ad6bca0 R15: ffffc90003bb7e04
FS:  0000555556ed2380(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000160d398 CR3: 000000007809c000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 bpf_struct_ops_map_alloc+0x12f/0x5d0 kernel/bpf/bpf_struct_ops.c:674
 map_create+0x548/0x1b90 kernel/bpf/syscall.c:1237
 __sys_bpf+0xa32/0x4a00 kernel/bpf/syscall.c:5445
 __do_sys_bpf kernel/bpf/syscall.c:5567 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5565 [inline]
 __x64_sys_bpf+0x78/0xc0 kernel/bpf/syscall.c:5565
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f9f205ef2e9
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fffa4ce4088 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007fffa4ce4268 RCX: 00007f9f205ef2e9
RDX: 0000000000000048 RSI: 00000000200004c0 RDI: 0000000000000000
RBP: 00007f9f20662610 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000ffffffff R11: 0000000000000246 R12: 0000000000000001
R13: 00007fffa4ce4258 R14: 0000000000000001 R15: 0000000000000001
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:bpf_struct_ops_find_value+0x49/0x140 kernel/bpf/btf.c:8763
Code: 7d ea dd ff 45 85 e4 0f 84 d7 00 00 00 e8 ff ee dd ff 48 8d bb 88 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 dc 00 00 00 48 8b 9b 88 00 00 00 48 85 db 0f 84
RSP: 0018:ffffc90003bb7b20 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff81aa3283
RDX: 0000000000000011 RSI: ffffffff81aa3291 RDI: 0000000000000088
RBP: ffffc90003bb7dd0 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000000 R12: 0000000000000002
R13: 000000000000001a R14: ffffffff8ad6bca0 R15: ffffc90003bb7e04
FS:  0000555556ed2380(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000160d398 CR3: 000000007809c000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess), 4 bytes skipped:
   0:	45 85 e4             	test   %r12d,%r12d
   3:	0f 84 d7 00 00 00    	je     0xe0
   9:	e8 ff ee dd ff       	call   0xffddef0d
   e:	48 8d bb 88 00 00 00 	lea    0x88(%rbx),%rdi
  15:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax
  1c:	fc ff df
  1f:	48 89 fa             	mov    %rdi,%rdx
  22:	48 c1 ea 03          	shr    $0x3,%rdx
* 26:	80 3c 02 00          	cmpb   $0x0,(%rdx,%rax,1) <-- trapping instruction
  2a:	0f 85 dc 00 00 00    	jne    0x10c
  30:	48 8b 9b 88 00 00 00 	mov    0x88(%rbx),%rbx
  37:	48 85 db             	test   %rbx,%rbx
  3a:	0f                   	.byte 0xf
  3b:	84                   	.byte 0x84

Crashes (9):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/01/24 16:45 bpf-next d47b9f68d289 1e153dc8 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_find_value
2024/01/24 18:17 bpf-next d47b9f68d289 1e153dc8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_find_value
2024/01/24 16:21 bpf-next d47b9f68d289 1e153dc8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_find_value
2024/01/24 14:59 bpf-next d47b9f68d289 1e153dc8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_find_value
2024/01/28 09:23 linux-next 01af33cc9894 cc4a4020 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root general protection fault in bpf_struct_ops_find_value
2024/01/26 18:34 linux-next 01af33cc9894 cc4a4020 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root general protection fault in bpf_struct_ops_find_value
2024/01/26 01:57 linux-next 01af33cc9894 cc4a4020 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root general protection fault in bpf_struct_ops_find_value
2024/01/25 08:56 linux-next 01af33cc9894 1e153dc8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root general protection fault in bpf_struct_ops_find_value
2024/01/25 06:39 linux-next 01af33cc9894 1e153dc8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root general protection fault in bpf_struct_ops_find_value
* Struck through repros no longer work on HEAD.