[PATCH 0/3] tracing: Fix readonly backup instance blocking reads and autoremove races
From: Masami Hiramatsu (Google)
Date: Wed Dec 02 2026 - 10:05:33 EST
Hi,
This series fixes three issues in read-only backup trace instances
introduced by commits 2c79da099aac ("tracing: Make the backup instance
non-reusable") and eca33fdab47b ("tracing: Remove the backup instance
automatically after read"):
1. Blocking pipe reads, splice(), and TRACE_MMAP_IOCTL_GET_READER on
empty read-only backup instances hang forever when
update_last_data_if_empty() returns false (e.g., an empty per-CPU
buffer while another CPU still has data, a partial commit page under
splice(), or reads after TRACE_ARRAY_FL_LAST_BOOT is cleared). Patch 1
returns EOF (or -ENODEV for the ioctl) on empty read-only instances
while preserving non-blocking -EAGAIN and trace_poll() behavior.
2. __trace_array_get() rejects opens with -ENODEV as soon as
tr->free_on_close is set, breaking multi-fd consumers that still hold
open pipes while reading stats or truncating the trace file. Patch 2
tracks queued autoremove work in tr->autoremove_queued and rejects
opens only once autoremove is queued.
3. __remove_instance() calls cancel_work_sync() on autoremove_work while
holding event_mutex and trace_types_lock, causing an ABBA deadlock or
UAF/ABA race when rmdir or trace_array_destroy() races with
autoremove. Patch 3 lets trace_array_autoremove() exclusively destroy
tr once queued, and makes external destroy/rmdir callers drop the
locks, flush autoremove_wq, and return -ENODEV.
Thank you,
Masami Hiramatsu (Google) (3):
tracing: Return EOF instead of blocking on empty readonly instances
tracing: Reject backup instance opens only after autoremove is queued
tracing: Fix deadlock and UAF when rmdir races with backup autoremove
kernel/trace/trace.c | 108 ++++++++++++++++++++++++++++++-------------
kernel/trace/trace.h | 4 ++
2 files changed, 79 insertions(+), 33 deletions(-)
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.56.1.911.g883d8bcb20-goog