syzbot


general protection fault in bpf_struct_ops_link_create

Status: fixed on 2023/06/08 14:41
Subsystems: bpf net
[Documentation on labels]
Reported-by: syzbot+71ccc0fe37abb458406b@syzkaller.appspotmail.com
Fix commit: 55fbae05476d bpf: Check IS_ERR for the bpf_map_get() return value
First crash: 398d, last: 395d
Cause bisection: introduced by (bisect log) :
commit 68b04864ca425d1894c96b8141d4fba1181f11cb
Author: Kui-Feng Lee <kuifeng@meta.com>
Date: Thu Mar 23 03:24:00 2023 +0000

  bpf: Create links for BPF struct_ops maps.

Crash: general protection fault in bpf_struct_ops_link_create (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[PATCH bpf-next] bpf: Check IS_ERR for the bpf_map_get() return value 4 (4) 2023/03/24 19:50
[syzbot] [bpf?] [net?] general protection fault in bpf_struct_ops_link_create 2 (3) 2023/03/24 18:22

Sample crash report:
general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
CPU: 1 PID: 5081 Comm: syz-executor182 Not tainted 6.2.0-syzkaller-13084-g226bc6ae6405 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
RIP: 0010:bpf_struct_ops_valid_to_reg kernel/bpf/bpf_struct_ops.c:764 [inline]
RIP: 0010:bpf_struct_ops_link_create+0xb1/0x390 kernel/bpf/bpf_struct_ops.c:879
Code: 95 81 eb ff 48 85 c0 48 89 c5 0f 84 9e 02 00 00 e8 24 27 dd ff 48 8d 7d 18 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 60 02 00 00 44 8b 65 18 bf 1a
RSP: 0018:ffffc90003b8fc38 EFLAGS: 00010203
RAX: dffffc0000000000 RBX: 1ffff92000771f87 RCX: 0000000000000000
RDX: 0000000000000001 RSI: ffffffff81a7dc8c RDI: 000000000000000f
RBP: fffffffffffffff7 R08: 0000000000000007 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: dffffc0000000000
R13: 000000000000002c R14: ffffc90003b8fde8 R15: 0000000000000000
FS:  0000555556538300(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000eaa388 CR3: 00000000206d2000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 link_create kernel/bpf/syscall.c:4585 [inline]
 __sys_bpf+0x3b77/0x53b0 kernel/bpf/syscall.c:5129
 __do_sys_bpf kernel/bpf/syscall.c:5163 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5161 [inline]
 __x64_sys_bpf+0x79/0xc0 kernel/bpf/syscall.c:5161
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fc374490ae9
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fffe2184578 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc374490ae9
RDX: 0000000000000010 RSI: 0000000020001340 RDI: 000000000000001c
RBP: 00007fc374454c90 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000ffffffff R11: 0000000000000246 R12: 00007fc374454d20
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:bpf_struct_ops_valid_to_reg kernel/bpf/bpf_struct_ops.c:764 [inline]
RIP: 0010:bpf_struct_ops_link_create+0xb1/0x390 kernel/bpf/bpf_struct_ops.c:879
Code: 95 81 eb ff 48 85 c0 48 89 c5 0f 84 9e 02 00 00 e8 24 27 dd ff 48 8d 7d 18 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 60 02 00 00 44 8b 65 18 bf 1a
RSP: 0018:ffffc90003b8fc38 EFLAGS: 00010203
RAX: dffffc0000000000 RBX: 1ffff92000771f87 RCX: 0000000000000000
RDX: 0000000000000001 RSI: ffffffff81a7dc8c RDI: 000000000000000f
RBP: fffffffffffffff7 R08: 0000000000000007 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: dffffc0000000000
R13: 000000000000002c R14: ffffc90003b8fde8 R15: 0000000000000000
FS:  0000555556538300(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000eaa388 CR3: 00000000206d2000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	95                   	xchg   %eax,%ebp
   1:	81 eb ff 48 85 c0    	sub    $0xc08548ff,%ebx
   7:	48 89 c5             	mov    %rax,%rbp
   a:	0f 84 9e 02 00 00    	je     0x2ae
  10:	e8 24 27 dd ff       	callq  0xffdd2739
  15:	48 8d 7d 18          	lea    0x18(%rbp),%rdi
  19:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax
  20:	fc ff df
  23:	48 89 fa             	mov    %rdi,%rdx
  26:	48 c1 ea 03          	shr    $0x3,%rdx
* 2a:	0f b6 04 02          	movzbl (%rdx,%rax,1),%eax <-- trapping instruction
  2e:	84 c0                	test   %al,%al
  30:	74 08                	je     0x3a
  32:	3c 03                	cmp    $0x3,%al
  34:	0f 8e 60 02 00 00    	jle    0x29a
  3a:	44 8b 65 18          	mov    0x18(%rbp),%r12d
  3e:	bf                   	.byte 0xbf
  3f:	1a                   	.byte 0x1a

Crashes (17):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/03/24 00:52 bpf-next 226bc6ae6405 f94b4a29 .config strace log report syz C ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 14:36 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 11:58 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 11:14 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 10:18 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 09:28 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 08:29 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 06:25 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 05:54 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 05:01 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 03:08 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 02:28 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/24 00:36 bpf-next 226bc6ae6405 f94b4a29 .config console log report info ci-upstream-bpf-next-kasan-gce general protection fault in bpf_struct_ops_link_create
2023/03/26 17:40 linux-next e5dbf24e8b9e fbf0499a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root general protection fault in bpf_struct_ops_link_create
2023/03/26 02:24 linux-next e5dbf24e8b9e fbf0499a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root general protection fault in bpf_struct_ops_link_create
2023/03/25 22:59 linux-next e5dbf24e8b9e fbf0499a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root general protection fault in bpf_struct_ops_link_create
2023/03/25 13:39 linux-next e5dbf24e8b9e fbf0499a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root general protection fault in bpf_struct_ops_link_create
* Struck through repros no longer work on HEAD.