Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH v2 0/3] tracing: Fix readonly backup instance blocking reads and autoremove races
@ 2026-12-03  9:53 Masami Hiramatsu (Google)
  2026-12-03  9:54 ` [PATCH v2 1/3] tracing: Return EOF on empty readonly instances Masami Hiramatsu (Google)
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-12-03  9:53 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu
  Cc: Mathieu Desnoyers, linux-kernel, linux-trace-kernel

Hi,
 
This is v2 of the series fixing 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").

The previous version is here:
 https://lore.kernel.org/all/179622391385.9100.2915051158917183404.stgit@mhiramat.c.googlers.com/
 
Changes in v2:
 - [1/3] Check trace_array_is_readonly() before O_NONBLOCK /
   SPLICE_F_NONBLOCK so non-blocking reads and splices return EOF
   instead of -EAGAIN, and return EPOLLIN | EPOLLRDNORM in trace_poll().
 - [3/3] Consolidate trace_array_destroy() and instance_rmdir() via
   try_remove_instance(), and keep returning -ENODEV after
   flush_workqueue() to avoid double d_delete_notify() in vfs_rmdir().
 
1. Empty read-only backup instances block indefinitely (or return
   -EAGAIN on non-blocking reads/splices, or never wake in poll()) when
   update_last_data_if_empty() returns false. Patch 1 returns EOF
   (or -ENODEV for TRACE_MMAP_IOCTL_GET_READER) for both blocking and
   non-blocking callers, and returns EPOLLIN | EPOLLRDNORM in
   trace_poll().
 
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 consolidates trace_array_destroy() and
   instance_rmdir() so external callers drop the locks, flush
   autoremove_wq, and return -ENODEV.
 
 
Thank you,
 
Masami Hiramatsu (Google) (3):
  tracing: Return EOF 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 | 110 ++++++++++++++++++++++++++++---------------
 kernel/trace/trace.h |   4 ++
 2 files changed, 77 insertions(+), 37 deletions(-)
 
 
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.56.1.911.g883d8bcb20-goog

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-03 10:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  9:53 [PATCH v2 0/3] tracing: Fix readonly backup instance blocking reads and autoremove races Masami Hiramatsu (Google)
2026-12-03  9:54 ` [PATCH v2 1/3] tracing: Return EOF on empty readonly instances Masami Hiramatsu (Google)
2026-12-03 10:17   ` sashiko-bot
2026-12-03  9:54 ` [PATCH v2 2/3] tracing: Reject backup instance opens only after autoremove is queued Masami Hiramatsu (Google)
2026-12-03  9:54 ` [PATCH v2 3/3] tracing: Fix deadlock and UAF when rmdir races with backup autoremove Masami Hiramatsu (Google)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox