linux-stable/arch/parisc
Stephen Brennan 81d5125b08 kprobe/ftrace: bail out if ftrace was killed
[ Upstream commit 1a7d0890dd ]

If an error happens in ftrace, ftrace_kill() will prevent disarming
kprobes. Eventually, the ftrace_ops associated with the kprobes will be
freed, yet the kprobes will still be active, and when triggered, they
will use the freed memory, likely resulting in a page fault and panic.

This behavior can be reproduced quite easily, by creating a kprobe and
then triggering a ftrace_kill(). For simplicity, we can simulate an
ftrace error with a kernel module like [1]:

[1]: https://github.com/brenns10/kernel_stuff/tree/master/ftrace_killer

  sudo perf probe --add commit_creds
  sudo perf trace -e probe:commit_creds
  # In another terminal
  make
  sudo insmod ftrace_killer.ko  # calls ftrace_kill(), simulating bug
  # Back to perf terminal
  # ctrl-c
  sudo perf probe --del commit_creds

After a short period, a page fault and panic would occur as the kprobe
continues to execute and uses the freed ftrace_ops. While ftrace_kill()
is supposed to be used only in extreme circumstances, it is invoked in
FTRACE_WARN_ON() and so there are many places where an unexpected bug
could be triggered, yet the system may continue operating, possibly
without the administrator noticing. If ftrace_kill() does not panic the
system, then we should do everything we can to continue operating,
rather than leave a ticking time bomb.

Link: https://lore.kernel.org/all/20240501162956.229427-1-stephen.s.brennan@oracle.com/

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Acked-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-06-27 13:52:17 +02:00
..
boot parisc: Allow building uncompressed Linux kernel 2023-10-30 14:54:40 +01:00
configs staging: qlge: Retire the driver 2023-10-21 11:52:54 +02:00
include parisc: Try to fix random segmentation faults in package builds 2024-06-21 14:40:28 +02:00
kernel kprobe/ftrace: bail out if ftrace was killed 2024-06-27 13:52:17 +02:00
lib parisc: ucmpdi2: Fix no previous prototype for '__ucmpdi2' warning 2023-08-10 18:34:05 +02:00
math-emu parisc: avoid c23 'nullptr' idenitifier 2024-02-27 22:51:44 +01:00
mm parisc: Fix random data corruption from exception handler 2024-01-30 17:18:58 +01:00
net parisc: Add eBPF JIT compiler glue code and Makefile 2023-08-22 10:24:47 +02:00
video arch/parisc: Detect primary video device from device instance 2024-01-12 12:38:37 +01:00
defpalo.conf
install.sh kbuild: factor out the common installation code into scripts/install.sh 2022-05-11 21:45:53 +09:00
Kbuild parisc: Wire up eBPF JIT compiler 2023-08-22 10:24:47 +02:00
Kconfig Kbuild updates for v6.9 2024-03-21 14:41:00 -07:00
Kconfig.debug parisc: Use page table locks only if DEBUG_KERNEL is enabled 2023-08-20 20:23:46 +02:00
Makefile kbuild: use 4-space indentation when followed by conditionals 2024-02-15 06:05:44 +09:00