kernel panic: Attempted to kill init!
Subsystems (4)
Hi,
This crash can be triggered by executing the C reproducer for multiple times, which just keep loading the following prog as raw tracepoint into kmem_cache_free().
The prog send SIGSEGV to current via bpf_send_signal_thread(), after load this, whoever tries to free mem would trigger this, kernel crashed when this happens to init.
Seems we should filter init out in bpf_send_signal_common() by is_global_init(current), or maybe we should check this in the verifier?
This can be reproduced on:
HEAD commit: 59fe41b5255f selftests/bpf: Add verifier test exercising jit PROBE_MEM logic git tree: bpf-next
console output: https://pastebin.com/raw/FMgyvEnH
kernel config : https://pastebin.com/raw/XeF6jU43
C reproducer : https://pastebin.com/raw/Tag5N893
func#0 @0
0: R1=ctx(off=0,imm=0) R10=fp0
0: (18) r0 = 0x0 ; R0_w=0 2: (18) r6 = 0x0 ; R6_w=0 4: (18) r7 = 0x0 ; R7_w=0 6: (18) r8 = 0x0 ; R8_w=0 8: (18) r9 = 0x0 ; R9_w=0
10: (2d) if r0 > r0 goto pc+2last_idx 10 first_idx 0
regs=1 stack=0 before 8: (18) r9 = 0x0
regs=1 stack=0 before 6: (18) r8 = 0x0
regs=1 stack=0 before 4: (18) r7 = 0x0
regs=1 stack=0 before 2: (18) r6 = 0x0
regs=1 stack=0 before 0: (18) r0 = 0x0last_idx 10 first_idx 0
regs=1 stack=0 before 8: (18) r9 = 0x0
regs=1 stack=0 before 6: (18) r8 = 0x0
regs=1 stack=0 before 4: (18) r7 = 0x0
regs=1 stack=0 before 2: (18) r6 = 0x0
regs=1 stack=0 before 0: (18) r0 = 0x0
11: R0_w=0
11: (b7) r1 = 11 ; R1_w=11
12: (85) call bpf_send_signal_thread#117 ; R0=scalar()
13: (95) exit
processed 9 insns (limit 1000000) max_states_per_insn 0 total_states 1 peak_states 1 mark_read 1
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b CPU: 3 PID: 1 Comm: systemd Not tainted 6.1.0-09652-g59fe41b5255f #148 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x100/0x178 lib/dump_stack.c:106 panic+0x2c4/0x60f kernel/panic.c:275 do_exit.cold+0x63/0xe4 kernel/exit.c:789 do_group_exit+0xd4/0x2a0 kernel/exit.c:950 get_signal+0x2460/0x2600 kernel/signal.c:2858 arch_do_signal_or_restart+0x78/0x5d0 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x55e738964df0 Code: 00 31 f6 89 ef 4c 8d 05 be 1b 0d 00 48 8d 15 b0 85 0c 00 31 c0 e8 f0 c3 ff ff e9 1c ff ff ff 66 66 2e 0f 1f 84 00 00 00 00 00 <41> 57 41 56 41 55 41 54 41 89 fc 55 53 48 81 ec 48 01 00 00 64 48 RSP: 002b:00007ffeb8e87bb8 EFLAGS: 00000246 ORIG_RAX: 00000000000000f7 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007f29dc8a6bc1 RDX: 00007ffeb8e87bc0 RSI: 00007ffeb8e87cf0 RDI: 000000000000000b RBP: 00007ffeb90b73c0 R08: 0000000000000000 R09: 0000000000000002 R10: 0000000000000004 R11: 0000000000000246 R12: 00007f29dc3f76c8 R13: 000000000000294d R14: 0000000000000000 R15: 00007ffeb9686870 </TASK>
Kernel Offset: disabled
Rebooting in 86400 seconds..
Quoted 6 lines · Hao Sun
Hi,
This crash can be triggered by executing the C reproducer for multiple times, which just keep loading the following prog as raw tracepoint into
kmem_cache_free().
Quoted 7 lines
The prog send SIGSEGV to current via
bpf_send_signal_thread(), after load this, whoever tries to free mem would trigger this, kernel crashed when this happens to init.Seems we should filter init out in
bpf_send_signal_common()byis_global_init(current), or maybe we should check this in the verifier?
The helper is just to send a particular signal to *current* thread. In typical use case, it is never a good idea to send the signal to a *random* thread. In certain cases, maybe user indeed wants to send the signal to init thread to observe something. Note that such destructive side effect already exists in the bpf land. For example, for a xdp program, it could drop all packets to make machine not responsive to ssh etc. Therefore, I recommend to keep the existing bpf_send_signal_common() helper behavior.
Quoted 64 lines
This can be reproduced on:
HEAD commit:
59fe41b5255fselftests/bpf: Add verifier test exercising jitPROBE_MEMlogic git tree: bpf-next
console output: https://pastebin.com/raw/FMgyvEnH
kernel config : https://pastebin.com/raw/XeF6jU43
C reproducer : https://pastebin.com/raw/Tag5N893func#0 @0
0: R1=ctx(off=0,imm=0) R10=fp00: (18) r0 = 0x0 ; R0_w=0 2: (18) r6 = 0x0 ; R6_w=0 4: (18) r7 = 0x0 ; R7_w=0 6: (18) r8 = 0x0 ; R8_w=0 8: (18) r9 = 0x0 ; R9_w=010: (2d) if r0 > r0 goto pc+2
last_idx10first_idx0
regs=1 stack=0 before 8: (18) r9 =0x0
regs=1 stack=0 before 6: (18) r8 =0x0
regs=1 stack=0 before 4: (18) r7 =0x0
regs=1 stack=0 before 2: (18) r6 =0x0
regs=1 stack=0 before 0: (18) r0 =0x0last_idx10first_idx0
regs=1 stack=0 before 8: (18) r9 =0x0
regs=1 stack=0 before 6: (18) r8 =0x0
regs=1 stack=0 before 4: (18) r7 =0x0
regs=1 stack=0 before 2: (18) r6 =0x0
regs=1 stack=0 before 0: (18) r0 =0x0
11: R0_w=0
11: (b7) r1 = 11 ; R1_w=11
12: (85) call bpf_send_signal_thread#117 ; R0=scalar()
13: (95) exit
processed 9 insns (limit 1000000)max_states_per_insn0total_states1peak_states1mark_read1Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b CPU: 3 PID: 1 Comm: systemd Not tainted 6.1.0-09652-g59fe41b5255f #148 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x100/0x178 lib/dump_stack.c:106 panic+0x2c4/0x60f kernel/panic.c:275 do_exit.cold+0x63/0xe4 kernel/exit.c:789 do_group_exit+0xd4/0x2a0 kernel/exit.c:950 get_signal+0x2460/0x2600 kernel/signal.c:2858 arch_do_signal_or_restart+0x78/0x5d0 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x55e738964df0 Code: 00 31 f6 89 ef 4c 8d 05 be 1b 0d 00 48 8d 15 b0 85 0c 00 31 c0 e8 f0 c3 ff ff e9 1c ff ff ff 66 66 2e 0f 1f 84 00 00 00 00 00 <41> 57 41 56 41 55 41 54 41 89 fc 55 53 48 81 ec 48 01 00 00 64 48 RSP: 002b:00007ffeb8e87bb8 EFLAGS: 00000246 ORIG_RAX: 00000000000000f7 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007f29dc8a6bc1 RDX: 00007ffeb8e87bc0 RSI: 00007ffeb8e87cf0 RDI: 000000000000000b RBP: 00007ffeb90b73c0 R08: 0000000000000000 R09: 0000000000000002 R10: 0000000000000004 R11: 0000000000000246 R12: 00007f29dc3f76c8 R13: 000000000000294d R14: 0000000000000000 R15: 00007ffeb9686870 </TASK>Kernel Offset: disabled
Rebooting in 86400 seconds..
Quoted 18 lines · Yonghong Song
Quoted 10 lines · Hao Sun
Hi,
This crash can be triggered by executing the C reproducer for multiple times, which just keep loading the following prog as raw tracepoint intokmem_cache_free().
The prog send SIGSEGV to current viabpf_send_signal_thread(), after load this, whoever tries to free mem would trigger this, kernel crashed when this happens to init.
Seems we should filter init out inbpf_send_signal_common()byis_global_init(current), or maybe we should check this in the verifier?
Quoted 9 lines
The helper is just to send a particular signal to *current* thread. In typical use case, it is never a good idea to send the signal to a *random* thread. In certain cases, maybe user indeed wants to send the signal to init thread to observe something. Note that such destructive side effect already exists in the bpf land. For example, for a xdp program, it could drop all packets to make machine not responsive to ssh etc. Therefore, I recommend to keep the existing
bpf_send_signal_common()helper behavior.
Sound the two are different cases. Not responsive in XDP seems like an intended behaviour, panic caused by killing init is buggy. If the last thread of global init was killed, kernel panic immediately.
Quoted 61 lines
Quoted 61 lines
This can be reproduced on:
HEAD commit:59fe41b5255fselftests/bpf: Add verifier test exercising jitPROBE_MEMlogic git tree: bpf-next
console output: https://pastebin.com/raw/FMgyvEnH
kernel config : https://pastebin.com/raw/XeF6jU43
C reproducer : https://pastebin.com/raw/Tag5N893
func#0 @0
0: R1=ctx(off=0,imm=0) R10=fp00: (18) r0 = 0x0 ; R0_w=0 2: (18) r6 = 0x0 ; R6_w=0 4: (18) r7 = 0x0 ; R7_w=0 6: (18) r8 = 0x0 ; R8_w=0 8: (18) r9 = 0x0 ; R9_w=010: (2d) if r0 > r0 goto pc+2
last_idx10first_idx0
regs=1 stack=0 before 8: (18) r9 =0x0
regs=1 stack=0 before 6: (18) r8 =0x0
regs=1 stack=0 before 4: (18) r7 =0x0
regs=1 stack=0 before 2: (18) r6 =0x0
regs=1 stack=0 before 0: (18) r0 =0x0last_idx10first_idx0
regs=1 stack=0 before 8: (18) r9 =0x0
regs=1 stack=0 before 6: (18) r8 =0x0
regs=1 stack=0 before 4: (18) r7 =0x0
regs=1 stack=0 before 2: (18) r6 =0x0
regs=1 stack=0 before 0: (18) r0 =0x0
11: R0_w=0
11: (b7) r1 = 11 ; R1_w=11
12: (85) call bpf_send_signal_thread#117 ; R0=scalar()
13: (95) exit
processed 9 insns (limit 1000000)max_states_per_insn0total_states1peak_states1mark_read1Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b CPU: 3 PID: 1 Comm: systemd Not tainted 6.1.0-09652-g59fe41b5255f #148 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x100/0x178 lib/dump_stack.c:106 panic+0x2c4/0x60f kernel/panic.c:275 do_exit.cold+0x63/0xe4 kernel/exit.c:789 do_group_exit+0xd4/0x2a0 kernel/exit.c:950 get_signal+0x2460/0x2600 kernel/signal.c:2858 arch_do_signal_or_restart+0x78/0x5d0 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x55e738964df0 Code: 00 31 f6 89 ef 4c 8d 05 be 1b 0d 00 48 8d 15 b0 85 0c 00 31 c0 e8 f0 c3 ff ff e9 1c ff ff ff 66 66 2e 0f 1f 84 00 00 00 00 00 <41> 57 41 56 41 55 41 54 41 89 fc 55 53 48 81 ec 48 01 00 00 64 48 RSP: 002b:00007ffeb8e87bb8 EFLAGS: 00000246 ORIG_RAX: 00000000000000f7 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007f29dc8a6bc1 RDX: 00007ffeb8e87bc0 RSI: 00007ffeb8e87cf0 RDI: 000000000000000b RBP: 00007ffeb90b73c0 R08: 0000000000000000 R09: 0000000000000002 R10: 0000000000000004 R11: 0000000000000246 R12: 00007f29dc3f76c8 R13: 000000000000294d R14: 0000000000000000 R15: 00007ffeb9686870 </TASK>Kernel Offset: disabled
Rebooting in 86400 seconds..
Quoted 29 lines · Hao Sun
Quoted 19 lines · Yonghong Song
Quoted 10 lines · Hao Sun
Hi,
This crash can be triggered by executing the C reproducer for multiple times, which just keep loading the following prog as raw tracepoint intokmem_cache_free().
The prog send SIGSEGV to current viabpf_send_signal_thread(), after load this, whoever tries to free mem would trigger this, kernel crashed when this happens to init.
Seems we should filter init out inbpf_send_signal_common()byis_global_init(current), or maybe we should check this in the verifier?Quoted 9 lines
The helper is just to send a particular signal to *current* thread. In typical use case, it is never a good idea to send the signal to a *random* thread. In certain cases, maybe user indeed wants to send the signal to init thread to observe something. Note that such destructive side effect already exists in the bpf land. For example, for a xdp program, it could drop all packets to make machine not responsive to ssh etc. Therefore, I recommend to keep the existing
bpf_send_signal_common()helper behavior.
Quoted 3 lines
Sound the two are different cases. Not responsive in XDP seems like an intended behaviour, panic caused by killing init is buggy. If the last thread of global init was killed, kernel panic immediately.
I don't get it. How was it possible that this prog was executed with current == pid 1 ?
Quoted 34 lines · Alexei Starovoitov
Quoted 29 lines · Hao Sun
Quoted 28 lines · Yonghong Song
Quoted 10 lines · Hao Sun
Hi,
This crash can be triggered by executing the C reproducer for multiple times, which just keep loading the following prog as raw tracepoint intokmem_cache_free().
The prog send SIGSEGV to current viabpf_send_signal_thread(), after load this, whoever tries to free mem would trigger this, kernel crashed when this happens to init.
Seems we should filter init out inbpf_send_signal_common()byis_global_init(current), or maybe we should check this in the verifier?The helper is just to send a particular signal to *current* thread. In typical use case, it is never a good idea to send the signal to a *random* thread. In certain cases, maybe user indeed wants to send the signal to init thread to observe something. Note that such destructive side effect already exists in the bpf land. For example, for a xdp program, it could drop all packets to make machine not responsive to ssh etc. Therefore, I recommend to keep the existing
bpf_send_signal_common()helper behavior.
Quoted 6 lines
Quoted 3 lines
Sound the two are different cases. Not responsive in XDP seems like an intended behaviour, panic caused by killing init is buggy. If the last thread of global init was killed, kernel panic immediately.
I don't get it. How was it possible that this prog was executed with current == pid 1 ?
The prog is raw trace point and is attached to ‘kmem_cache_free’ event. When init triggered the event, the prog would be executed with pid 1. But, the reason of this crash is not very clear to me, because it’s really hard to debug with original C reproducer.
The following is the corresponding Syz prog:
# {Threaded:true Repeat:true RepeatTimes:0 Procs:1 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:true NetDevices:true NetReset:true Cgroups:true BinfmtMisc:true CloseFDs:true KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:true Sysctl:true UseTmpDir:true HandleSegv:true Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} r0 = bpf$BPF_PROG_RAW_TRACEPOINT_LOAD(0x5, &(0x7f0000000000)={0x11, 0xe, &(0x7f0000000400)=ANY=[@ANYBLOB="18000000000000000000000000000000180600000000000000000000000000001807000000000000000000000000000018080000000000000000000000000000180900000000000000000000000000002d00020000000000b70100000b000000850000007500000095"], &(0x7f00000000c0)}, 0x80) bpf$BPF_RAW_TRACEPOINT_OPEN(0x11, &(0x7f0000000100)={&(0x7f0000000080)='kmem_cache_free\x00', r0}, 0x10)
Quoted 47 lines · Hao Sun
Quoted 35 lines · Alexei Starovoitov
Quoted 29 lines · Hao Sun
Quoted 28 lines · Yonghong Song
Quoted 10 lines · Hao Sun
Hi,
This crash can be triggered by executing the C reproducer for multiple times, which just keep loading the following prog as raw tracepoint intokmem_cache_free().
The prog send SIGSEGV to current viabpf_send_signal_thread(), after load this, whoever tries to free mem would trigger this, kernel crashed when this happens to init.
Seems we should filter init out inbpf_send_signal_common()byis_global_init(current), or maybe we should check this in the verifier?The helper is just to send a particular signal to *current* thread. In typical use case, it is never a good idea to send the signal to a *random* thread. In certain cases, maybe user indeed wants to send the signal to init thread to observe something. Note that such destructive side effect already exists in the bpf land. For example, for a xdp program, it could drop all packets to make machine not responsive to ssh etc. Therefore, I recommend to keep the existing
bpf_send_signal_common()helper behavior.Quoted 6 lines
Quoted 3 lines
Sound the two are different cases. Not responsive in XDP seems like an intended behaviour, panic caused by killing init is buggy. If the last thread of global init was killed, kernel panic immediately.
I don't get it. How was it possible that this prog was executed with current == pid 1 ?
The prog is raw trace point and is attached to ‘kmem_cache_free’ event. When init triggered the event, the prog would be executed with pid 1. But, the reason of this crash is not very clear to me, because it’s really hard to debug with original C reproducer.
Quoted 5 lines
The following is the corresponding Syz prog:
# {Threaded:true Repeat:true RepeatTimes:0 Procs:1 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:true NetDevices:true NetReset:true Cgroups:true BinfmtMisc:true CloseFDs:true KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:true Sysctl:true UseTmpDir:true HandleSegv:true Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} r0 = bpf$BPF_PROG_RAW_TRACEPOINT_LOAD(0x5, &(0x7f0000000000)={0x11,
0xe, &(0x7f0000000400)=ANY=[@ANYBLOB="18000000000000000000000000000000180600000000000000000000000000001807000000000000000000000000000018080000000000000000000000000000180900000000000000000000000000002d00020000000000b70100000b000000850000007500000095"], &(0x7f00000000c0)},0x80) bpf$BPF_RAW_TRACEPOINT_OPEN(0x11, &(0x7f0000000100)={&(0x7f0000000080)='kmem_cache_free\x00', r0},0x10)
Does syzbot running without any user space?
Is syzbot itself a pid=1 ? and the only process ? If so, the error would makes sense.
I guess we can add a safety check to bpf_send_signal_common to prevent syzbot from killing itself.
Quoted 54 lines · Alexei Starovoitov
Quoted 49 lines · Hao Sun
Quoted 35 lines · Alexei Starovoitov
Quoted 29 lines · Hao Sun
Quoted 28 lines · Yonghong Song
Quoted 10 lines · Hao Sun
Hi,
This crash can be triggered by executing the C reproducer for multiple times, which just keep loading the following prog as raw tracepoint intokmem_cache_free().
The prog send SIGSEGV to current viabpf_send_signal_thread(), after load this, whoever tries to free mem would trigger this, kernel crashed when this happens to init.
Seems we should filter init out inbpf_send_signal_common()byis_global_init(current), or maybe we should check this in the verifier?The helper is just to send a particular signal to *current* thread. In typical use case, it is never a good idea to send the signal to a *random* thread. In certain cases, maybe user indeed wants to send the signal to init thread to observe something. Note that such destructive side effect already exists in the bpf land. For example, for a xdp program, it could drop all packets to make machine not responsive to ssh etc. Therefore, I recommend to keep the existing
bpf_send_signal_common()helper behavior.Quoted 6 lines
Quoted 3 lines
Sound the two are different cases. Not responsive in XDP seems like an intended behaviour, panic caused by killing init is buggy. If the last thread of global init was killed, kernel panic immediately.
I don't get it. How was it possible that this prog was executed with current == pid 1 ?
The prog is raw trace point and is attached to ‘kmem_cache_free’ event. When init triggered the event, the prog would be executed with pid 1. But, the reason of this crash is not very clear to me, because it’s really hard to debug with original C reproducer.
The following is the corresponding Syz prog:
Quoted 7 lines
Quoted 3 lines
# {Threaded:true Repeat:true RepeatTimes:0 Procs:1 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:true NetDevices:true NetReset:true Cgroups:true BinfmtMisc:true CloseFDs:true KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:true Sysctl:true UseTmpDir:true HandleSegv:true Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} r0 = bpf$BPF_PROG_RAW_TRACEPOINT_LOAD(0x5, &(0x7f0000000000)={0x11,
0xe, &(0x7f0000000400)=ANY=[@ANYBLOB="18000000000000000000000000000000180600000000000000000000000000001807000000000000000000000000000018080000000000000000000000000000180900000000000000000000000000002d00020000000000b70100000b000000850000007500000095"], &(0x7f00000000c0)},0x80) bpf$BPF_RAW_TRACEPOINT_OPEN(0x11, &(0x7f0000000100)={&(0x7f0000000080)='kmem_cache_free\x00', r0},0x10)Does syzbot running without any user space?
Is syzbot itself a pid=1 ? and the only process ? If so, the error would makes sense.
Yes, after read the C reproducer again, noticed that after a bunch of sandbox setup, the pid of the reproducer process at runtime is 1.
Quoted 2 lines
I guess we can add a safety check to
bpf_send_signal_commonto prevent syzbot from killing itself.
Maybe something like this? This can avoid the panic, but won’t allow task with pid=1 to send signal with prog.
kernel/trace/bpf_trace.c +2 -0
@@ -844,6 +844,8 @@ static int bpf_send_signal_common(u32 sig, enum pid_type type)*/ if (unlikely (current->flags & (PF_KTHREAD |PF_EXITING )))return -EPERM ; +if (unlikely (is_global_init (current))) +return -EPERM ;if (unlikely (!nmi_uaccess_okay ()))return -EPERM ;
Quoted 20 lines · Hao Sun
Quoted 4 lines
Does syzbot running without any user space?
Is syzbot itself a pid=1 ? and the only process ? If so, the error would makes sense.Yes, after read the C reproducer again, noticed that after a bunch of sandbox setup, the pid of the reproducer process at runtime is 1.
Quoted 2 lines
I guess we can add a safety check to
bpf_send_signal_commonto prevent syzbot from killing itself.Maybe something like this? This can avoid the panic, but won’t allow task with pid=1 to send signal with prog.
kernel/trace/bpf_trace.c +0
-0
kernel/trace/bpf_trace.c static int bpf_send_signal_common(u32 sig, enum pid_type type) · line 850
Quoted 7 lines
kernel/trace/bpf_trace.c +2
-0@@ -844,6 +844,8 @@ static int bpf_send_signal_common(u32 sig, enum pid_type type)*/ if (unlikely (current->flags & (PF_KTHREAD |PF_EXITING )))return -EPERM ; +if (unlikely (is_global_init (current))) +return -EPERM ;if (unlikely (!nmi_uaccess_okay ()))return -EPERM ;
Yep. Good idea. Pls send an official patch.