linux-stable/arch/s390
Stephen Brennan ae0d1ea3e8 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:49:03 +02:00
..
appldata sysctl: Add size to register_sysctl 2023-08-15 15:26:17 -07:00
boot s390/boot: Remove alt_stfle_fac_list from decompressor 2024-06-12 11:12:33 +02:00
configs cred: get rid of CONFIG_DEBUG_CREDENTIALS 2023-12-20 17:01:51 +01:00
crypto crypto: s390/aes - Fix buffer overread in CTR mode 2024-01-31 16:18:50 -08:00
hypfs s390 updates for 6.6 merge window 2023-08-28 17:22:39 -07:00
include s390/cpacf: Make use of invalid opcode produce a link error 2024-06-16 13:47:46 +02:00
kernel kprobe/ftrace: bail out if ftrace was killed 2024-06-27 13:49:03 +02:00
kvm s390/mm: Re-enable the shared zeropage for !PV and !skeys KVM guests 2024-06-12 11:11:33 +02:00
lib s390: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-09 15:20:50 +02:00
mm s390/mm: Re-enable the shared zeropage for !PV and !skeys KVM guests 2024-06-12 11:11:33 +02:00
net s390/bpf: Emit a barrier for BPF_FETCH instructions 2024-06-12 11:11:53 +02:00
pci s390: use the correct count for __iowrite64_copy() 2024-03-01 13:35:08 +01:00
purgatory s390 updates for 6.5 merge window part 2 2023-07-06 13:18:30 -07:00
tools KVM: s390: Add facility 197 to the allow list 2022-07-13 15:25:25 +02:00
Kbuild - An extensive rework of kexec and crash Kconfig from Eric DeVolder 2023-08-29 14:53:51 -07:00
Kconfig kexec: fix KEXEC_FILE dependencies 2024-01-05 15:19:41 +01:00
Kconfig.debug
Makefile kbuild: unify vdso_install rules 2024-06-12 11:12:32 +02:00