syzbot


general protection fault in bpf_prog_array_delete_safe

Status: upstream: reported C repro on 2024/12/06 13:47
Subsystems: bpf
[Documentation on labels]
Reported-by: syzbot+2e0d2840414ce817aaac@syzkaller.appspotmail.com
Fix commit: 978c4486cca5 bpf,perf: Fix invalid prog_array access in perf_event_detach_bpf_prog
Patched on: [ci-qemu-gce-upstream-auto ci-qemu-native-arm64-kvm ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-snapshot-upstream-root ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-arm64 ci-upstream-gce-leak ci-upstream-kasan-badwrites-root ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-kmsan-gce-386-root ci-upstream-kmsan-gce-root ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-fs ci2-upstream-kcsan-gce ci2-upstream-usb], missing on: [ci-qemu2-arm32 ci-qemu2-riscv64]
First crash: 15d, last: 13d
Cause bisection: introduced by (bisect log) :
commit 0ee288e69d033850bc87abe0f9cc3ada24763d7f
Author: Jiri Olsa <jolsa@kernel.org>
Date: Wed Oct 23 20:03:52 2024 +0000

  bpf,perf: Fix perf_event_detach_bpf_prog error handling

Crash: BUG: unable to handle kernel NULL pointer dereference in bpf_prog_array_delete_safe (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[PATCH bpf] bpf,perf: Fix invalid prog_array access in perf_event_detach_bpf_prog 2 (2) 2024/12/10 18:30
[syzbot] [bpf?] general protection fault in bpf_prog_array_delete_safe 1 (3) 2024/12/07 01:01

Sample crash report:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 0 UID: 0 PID: 5849 Comm: syz-executor326 Not tainted 6.12.0-syzkaller-09099-ge2cf913314b9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
RIP: 0010:bpf_prog_array_delete_safe+0x2d/0xc0 kernel/bpf/core.c:2583
Code: 00 41 57 41 56 41 55 41 54 53 49 89 f7 49 89 fd 49 bc 00 00 00 00 00 fc ff df e8 ce 84 f0 ff 4d 8d 75 10 4c 89 f0 48 c1 e8 03 <42> 80 3c 20 00 74 08 4c 89 f7 e8 54 6b 5b 00 49 8b 1e 48 85 db 74
RSP: 0018:ffffc90003807970 EFLAGS: 00010202
RAX: 0000000000000002 RBX: 1ffff92000700f38 RCX: ffff888034eb8000
RDX: 0000000000000000 RSI: ffffc90000abe000 RDI: 0000000000000000
RBP: ffffc90003807a48 R08: ffffffff81a1aa9e R09: 1ffffffff203c816
R10: dffffc0000000000 R11: fffffbfff203c817 R12: dffffc0000000000
R13: 0000000000000000 R14: 0000000000000010 R15: ffffc90000abe000
FS:  0000000000000000(0000) GS:ffff8880b8600000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000000e738000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 perf_event_detach_bpf_prog+0x2b0/0x330 kernel/trace/bpf_trace.c:2255
 perf_event_free_bpf_prog kernel/events/core.c:10801 [inline]
 _free_event+0xb04/0xf60 kernel/events/core.c:5352
 put_event kernel/events/core.c:5454 [inline]
 perf_event_release_kernel+0x7c1/0x850 kernel/events/core.c:5579
 perf_release+0x38/0x40 kernel/events/core.c:5589
 __fput+0x23c/0xa50 fs/file_table.c:450
 task_work_run+0x24f/0x310 kernel/task_work.c:239
 exit_task_work include/linux/task_work.h:43 [inline]
 do_exit+0xa2f/0x28e0 kernel/exit.c:938
 do_group_exit+0x207/0x2c0 kernel/exit.c:1087
 __do_sys_exit_group kernel/exit.c:1098 [inline]
 __se_sys_exit_group kernel/exit.c:1096 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1096
 x64_sys_call+0x26a8/0x26b0 arch/x86/include/generated/asm/syscalls_64.h:232
 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:0x7f9408276e09
Code: Unable to access opcode bytes at 0x7f9408276ddf.
RSP: 002b:00007fffe6c98ad8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f9408276e09
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 00007f94082f22b0 R08: ffffffffffffffb8 R09: 0000000000000006
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f94082f22b0
R13: 0000000000000000 R14: 00007f94082f2d00 R15: 00007f9408248040
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:bpf_prog_array_delete_safe+0x2d/0xc0 kernel/bpf/core.c:2583
Code: 00 41 57 41 56 41 55 41 54 53 49 89 f7 49 89 fd 49 bc 00 00 00 00 00 fc ff df e8 ce 84 f0 ff 4d 8d 75 10 4c 89 f0 48 c1 e8 03 <42> 80 3c 20 00 74 08 4c 89 f7 e8 54 6b 5b 00 49 8b 1e 48 85 db 74
RSP: 0018:ffffc90003807970 EFLAGS: 00010202
RAX: 0000000000000002 RBX: 1ffff92000700f38 RCX: ffff888034eb8000
RDX: 0000000000000000 RSI: ffffc90000abe000 RDI: 0000000000000000
RBP: ffffc90003807a48 R08: ffffffff81a1aa9e R09: 1ffffffff203c816
R10: dffffc0000000000 R11: fffffbfff203c817 R12: dffffc0000000000
R13: 0000000000000000 R14: 0000000000000010 R15: ffffc90000abe000
FS:  0000000000000000(0000) GS:ffff8880b8600000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000007f382000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	00 41 57             	add    %al,0x57(%rcx)
   3:	41 56                	push   %r14
   5:	41 55                	push   %r13
   7:	41 54                	push   %r12
   9:	53                   	push   %rbx
   a:	49 89 f7             	mov    %rsi,%r15
   d:	49 89 fd             	mov    %rdi,%r13
  10:	49 bc 00 00 00 00 00 	movabs $0xdffffc0000000000,%r12
  17:	fc ff df
  1a:	e8 ce 84 f0 ff       	call   0xfff084ed
  1f:	4d 8d 75 10          	lea    0x10(%r13),%r14
  23:	4c 89 f0             	mov    %r14,%rax
  26:	48 c1 e8 03          	shr    $0x3,%rax
* 2a:	42 80 3c 20 00       	cmpb   $0x0,(%rax,%r12,1) <-- trapping instruction
  2f:	74 08                	je     0x39
  31:	4c 89 f7             	mov    %r14,%rdi
  34:	e8 54 6b 5b 00       	call   0x5b6b8d
  39:	49 8b 1e             	mov    (%r14),%rbx
  3c:	48 85 db             	test   %rbx,%rbx
  3f:	74                   	.byte 0x74

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/06 13:34 bpf e2cf913314b9 946d28f0 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-bpf-kasan-gce general protection fault in bpf_prog_array_delete_safe
2024/12/06 12:00 bpf e2cf913314b9 946d28f0 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-bpf-kasan-gce general protection fault in bpf_prog_array_delete_safe
2024/12/06 10:30 bpf e2cf913314b9 946d28f0 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-bpf-kasan-gce general protection fault in bpf_prog_array_delete_safe
2024/12/08 12:21 bpf b5f217084ab3 9ac0fdc6 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-kasan-gce general protection fault in bpf_prog_array_delete_safe
2024/12/06 09:37 bpf e2cf913314b9 946d28f0 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-kasan-gce general protection fault in bpf_prog_array_delete_safe
* Struck through repros no longer work on HEAD.