All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] tracing: Return EOF on empty readonly instances
Date: Thu, 03 Dec 2026 10:17:42 +0000	[thread overview]
Message-ID: <sashiko-outbox-247560@kernel.org> (raw)
In-Reply-To: <179629164246.2691692.4666270506346866296.stgit@mhiramat.c.googlers.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] tracing: readonly splice EOF skips
  update_last_data_if_empty()
--

commit 6492f59da7819633891017bc6387b13b6a84a5c4
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>

tracing: Return EOF on empty readonly instances

This commit returns EOF instead of blocking or returning -EAGAIN on
empty readonly trace instances in the pipe read, splice, and mmap reader
ioctl paths, and reports them as readable in trace_poll().

> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index fa65ef8d7fbea..b431606c6375f 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c

[ ... ]

> @@ -5369,6 +5369,10 @@ static int tracing_wait_pipe(struct file *filp)
>  
>  	while (trace_empty(iter)) {
>  
> +		/* Readonly instances can never receive new events. */
> +		if (trace_array_is_readonly(iter->tr))
> +			return 0;
> +
>  		if ((filp->f_flags & O_NONBLOCK)) {
>  			return -EAGAIN;
>  		}

[ ... ]

> @@ -7375,6 +7382,9 @@ ssize_t tracing_buffers_splice_read(struct file *file, loff_t *ppos,
>  		if (woken)
>  			goto out;
>  
> +		if (trace_array_is_readonly(iter->tr))
> +			goto out;
> +
>  		ret = -EAGAIN;
>  		if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
>  			goto out;

[Severity: Medium]
Should these splice EOF paths also call update_last_data_if_empty(iter->tr)?

Unlike tracing_read_pipe() and tracing_buffers_read(), neither
tracing_splice_read_pipe() (via tracing_wait_pipe()) nor
tracing_buffers_splice_read() calls update_last_data_if_empty(iter->tr)
before returning 0 on an empty readonly instance.

When a readonly backup instance is drained via splice() on trace_pipe or
trace_pipe_raw, TRACE_ARRAY_FL_LAST_BOOT is never cleared and
tr->free_on_close stays false, so closing the file descriptor does not
schedule automatic removal and the backup ring buffer stays allocated.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179629163198.2691692.6206990932650792224.stgit@mhiramat.c.googlers.com?part=1

  reply	other threads:[~2026-12-03 10:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-12-04  5:49     ` Masami Hiramatsu (Google)
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)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-247560@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.