All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] tracing: Fix readonly backup instance blocking reads and autoremove races
@ 2026-12-04  6:06 Masami Hiramatsu (Google)
  2026-12-04  6:06 ` [PATCH v3 1/3] tracing: Hold file reference in splice buffer_ref Masami Hiramatsu (Google)
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-12-04  6:06 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu
  Cc: Mathieu Desnoyers, linux-kernel, linux-trace-kernel

Hi,

This is v3 of the series fixing read-only backup trace instance read/splice
and autoremove issues, rebased onto linux-trace/trace/fixes (a6a40ab36abb,
which already includes v2 Patch 2 "tracing: Reject backup instance opens
only after autoremove is queued").

The previous version is here:
 https://lore.kernel.org/all/179629163198.2691692.6206990932650792224.stgit@mhiramat.c.googlers.com/

Changes in v3:
 - Rebase onto linux-trace/trace/fixes (a6a40ab36abb) and drop v2 [2/3]
   which is already applied.
 - [1/3] Newly added to hold a file reference in struct buffer_ref and
   prevent use-after-free when an instance is destroyed while spliced
   pages remain in a pipe.
 - [2/3] Move update_last_data_if_empty() into tracing_wait_pipe() and
   call it in tracing_buffers_splice_read() so draining via splice()
   schedules backup autoremove (reported by Sashiko).
 - [3/3] Unchanged from v2.

1. struct buffer_ref attached to pipe buffers by
   tracing_buffers_splice_read() holds a raw pointer to trace_buffer
   without pinning the source file. If trace_pipe_raw is closed while
   spliced pages remain in the pipe and the instance is destroyed (by
   rmdir or backup autoremove), buffer_ref_release() triggers a UAF.
   Patch 1 holds a get_file(file) reference in struct buffer_ref and
   releases it via fput() in buffer_ref_release().

2. 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, and draining via splice()
   never schedules backup autoremove. Patch 2 returns EOF (or -ENODEV for
   TRACE_MMAP_IOCTL_GET_READER), calls update_last_data_if_empty() on the
   splice EOF paths, and returns EPOLLIN | EPOLLRDNORM in trace_poll().

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: Hold file reference in splice buffer_ref
  tracing: Return EOF on empty readonly instances
  tracing: Fix deadlock and UAF when rmdir races with backup autoremove

 kernel/trace/trace.c | 111 ++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 74 insertions(+), 37 deletions(-)


base-commit: a6a40ab36abb91e698b08cc7a0d3dc9455fcfaf4
-- 
2.56.1.915.g69d5ec7298-goog

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

end of thread, other threads:[~2026-12-04 15:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  6:06 [PATCH v3 0/3] tracing: Fix readonly backup instance blocking reads and autoremove races Masami Hiramatsu (Google)
2026-12-04  6:06 ` [PATCH v3 1/3] tracing: Hold file reference in splice buffer_ref Masami Hiramatsu (Google)
2026-12-04  6:19   ` sashiko-bot
2026-12-04 15:33     ` Masami Hiramatsu (Google)
2026-12-04  6:07 ` [PATCH v3 2/3] tracing: Return EOF on empty readonly instances Masami Hiramatsu (Google)
2026-12-04  6:07 ` [PATCH v3 3/3] tracing: Fix deadlock and UAF when rmdir races with backup autoremove Masami Hiramatsu (Google)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.