linux/kernel/trace
Hao Sun a3d81bc1ea bpf: Skip task with pid=1 in send_signal_common()
The following kernel panic can be triggered when a task with pid=1 attaches
a prog that attempts to send killing signal to itself, also see [1] for more
details:

  Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
  CPU: 3 PID: 1 Comm: systemd Not tainted 6.1.0-09652-g59fe41b5255f #148
  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

So skip task with pid=1 in bpf_send_signal_common() to avoid the panic.

  [1] https://lore.kernel.org/bpf/20221222043507.33037-1-sunhao.th@gmail.com

Signed-off-by: Hao Sun <sunhao.th@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/20230106084838.12690-1-sunhao.th@gmail.com
2023-01-06 22:48:58 +01:00
..
rv rv/monitors: Move monitor structure in rodata 2022-12-20 11:46:40 -05:00
blktrace.c blktrace: Fix output non-blktrace event when blk_classic option enabled 2022-12-08 09:26:11 -07:00
bpf_trace.c bpf: Skip task with pid=1 in send_signal_common() 2023-01-06 22:48:58 +01:00
bpf_trace.h
error_report-traces.c
fgraph.c arm64 fixes for 5.19-rc1: 2022-06-03 14:05:34 -07:00
fprobe.c tracing/fprobe: Fix to check whether fprobe is registered correctly 2022-11-04 08:50:07 +09:00
ftrace_internal.h
ftrace.c Tracing updates for 6.2: 2022-12-15 18:01:16 -08:00
Kconfig powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
kprobe_event_gen_test.c tracing: kprobe: Fix potential null-ptr-deref on trace_array in kprobe_event_gen_test_exit() 2022-11-18 10:15:34 +09:00
Makefile rv: Add Runtime Verification (RV) interface 2022-07-30 14:01:28 -04:00
pid_list.c
pid_list.h
power-traces.c
preemptirq_delay_test.c
rethook.c rethook: fix a potential memleak in rethook_alloc() 2022-11-18 10:15:34 +09:00
ring_buffer_benchmark.c ring_buffer: Remove unused "event" parameter 2022-11-23 19:08:30 -05:00
ring_buffer.c ring-buffer: Handle resize in early boot up 2022-12-10 13:36:04 -05:00
rpm-traces.c
synth_event_gen_test.c tracing: Fix memory leak in test_gen_synth_cmd() and test_empty_synth_event() 2022-11-17 17:51:38 -05:00
trace_benchmark.c tracing: Add numeric delta time to the trace event benchmark 2022-09-26 13:01:09 -04:00
trace_benchmark.h tracing: Add numeric delta time to the trace event benchmark 2022-09-26 13:01:09 -04:00
trace_boot.c tracing: Initialize integer variable to prevent garbage return value 2022-05-26 21:13:00 -04:00
trace_branch.c
trace_clock.c
trace_dynevent.c tracing: Free buffers when a used dynamic event is removed 2022-11-23 19:07:12 -05:00
trace_dynevent.h
trace_entries.h
trace_eprobe.c tracing: Fix race where eprobes can be called before the event 2022-11-24 00:42:18 +09:00
trace_event_perf.c tracing/perf: Use strndup_user instead of kzalloc/strncpy_from_user 2022-11-23 19:08:31 -05:00
trace_events_filter_test.h
trace_events_filter.c tracing/filter: Call filter predicate functions directly via a switch statement 2022-09-26 13:01:10 -04:00
trace_events_hist.c tracing/hist: Fix issue of losting command info in error_log 2022-12-10 13:36:04 -05:00
trace_events_inject.c
trace_events_synth.c tracing: Fix issue of missing one synthetic field 2022-12-10 13:36:04 -05:00
trace_events_trigger.c tracing: Do not synchronize freeing of trigger filter on boot up 2022-12-14 08:50:56 -05:00
trace_events_user.c Tracing updates for 6.2: 2022-12-15 18:01:16 -08:00
trace_events.c tracing: remove unnecessary trace_trigger ifdef 2022-12-10 13:36:04 -05:00
trace_export.c
trace_functions_graph.c
trace_functions.c
trace_hwlat.c
trace_irqsoff.c
trace_kdb.c
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_kprobe.c trace/kprobe: remove duplicated calls of ring_buffer_event_data 2022-12-09 23:48:05 -05:00
trace_mmiotrace.c
trace_nop.c
trace_osnoise.c tracing/osnoise: Add preempt and/or irq disabled options 2022-12-10 13:36:05 -05:00
trace_output.c tracing: Fix some checker warnings 2022-12-10 13:36:05 -05:00
trace_output.h
trace_preemptirq.c tracing: hold caller_addr to hardirq_{enable,disable}_ip 2022-09-06 22:26:00 -04:00
trace_printk.c
trace_probe_kernel.h tracing: Add "(fault)" name injection to kernel probes 2022-10-12 13:50:20 -04:00
trace_probe_tmpl.h tracing/probes: Add symstr type for dynamic events 2022-12-15 08:48:57 +09:00
trace_probe.c Trace probes updates for 6.2: 2022-12-21 18:57:24 -08:00
trace_probe.h tracing/probes: Reject symbol/symstr type for uprobe 2022-12-15 09:00:20 +09:00
trace_recursion_record.c tracing: Use trace_create_file() to simplify creation of tracefs entries 2022-05-26 21:12:52 -04:00
trace_sched_switch.c sched/tracing: Append prev_state to tp args instead 2022-05-12 00:37:11 +02:00
trace_sched_wakeup.c sched/tracing: Append prev_state to tp args instead 2022-05-12 00:37:11 +02:00
trace_selftest_dynamic.c
trace_selftest.c x86/ftrace: Make it call depth tracking aware 2022-10-17 16:41:19 +02:00
trace_seq.c
trace_stack.c
trace_stat.c
trace_stat.h
trace_synth.h
trace_syscalls.c tracing: Remove unused __bad_type_size() method 2022-11-17 20:21:06 -05:00
trace_uprobe.c tracing/probes: Reject symbol/symstr type for uprobe 2022-12-15 09:00:20 +09:00
trace.c Trace probes updates for 6.2: 2022-12-21 18:57:24 -08:00
trace.h tracing: Fix some checker warnings 2022-12-10 13:36:05 -05:00
tracing_map.c tracing: Remove unused variable 'dups' 2022-10-03 12:20:31 -04:00
tracing_map.h