linux-stable/include
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
..
acpi ACPI: x86: Move acpi_quirk_skip_serdev_enumeration() out of CONFIG_X86_ANDROID_TABLETS 2024-04-13 13:07:31 +02:00
asm-generic sched: Add missing memory barrier in switch_mm_cid 2024-04-27 17:11:41 +02:00
clocksource
crypto crypto: af_alg - Disallow multiple in-flight AIO requests 2024-01-25 15:35:16 -08:00
drm drm/edid: Parse topology block for all DispID structure v1.x 2024-06-12 11:12:05 +02:00
dt-bindings clk: renesas: r8a779g0: Correct PFC/GPIO parent clocks 2024-03-26 18:19:47 -04:00
keys
kunit
kvm KVM: arm64: Fix host-programmed guest events in nVHE 2024-04-10 16:35:48 +02:00
linux kprobe/ftrace: bail out if ftrace was killed 2024-06-27 13:49:03 +02:00
math-emu
media media: cec: core: avoid recursive cec_claim_log_addrs 2024-06-12 11:12:43 +02:00
memory
misc
net net/sched: fix false lockdep warning on qdisc root lock 2024-06-27 13:49:02 +02:00
pcmcia
ras
rdma RDMA/core: Fix umem iterator when PAGE_SIZE is greater then HCA pgsz 2023-12-13 18:45:16 +01:00
rv
scsi scsi: mpi3mr: Fix ATA NCQ priority support 2024-06-21 14:38:25 +02:00
soc soc: qcom: rpmh-rsc: Enhance check for VRM in-flight request 2024-06-16 13:47:33 +02:00
sound ASoC: tas2781: Fix wrong loading calibrated data sequence 2024-06-12 11:12:47 +02:00
target
trace cachefiles: fix slab-use-after-free in cachefiles_ondemand_daemon_read() 2024-06-21 14:38:27 +02:00
uapi drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations 2024-06-12 11:12:45 +02:00
ufs
vdso
video fbdev: stifb: Make the STI next font pointer a 32-bit signed offset 2023-11-28 17:19:58 +00:00
xen xen/events: reduce externally visible helper functions 2024-03-01 13:34:57 +01:00