All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Matthew Wilcox <willy@infradead.org>,
	<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	David Howells <dhowells@redhat.com>
Subject: Re: [PATCH] pipe: fix potential use-after-free in pipe_read()
Date: Fri, 25 Nov 2022 15:52:53 +0800	[thread overview]
Message-ID: <3a38686c-040a-202c-2778-7670a2b3f087@huawei.com> (raw)
In-Reply-To: <Y4Bh0fTf4vZ6/6Pc@ZenIV>



On 2022/11/25 14:33, Al Viro wrote:
> On Thu, Nov 17, 2022 at 07:53:23PM +0800, Zhen Lei wrote:
>> Accessing buf->flags after pipe_buf_release(pipe, buf) is unsafe, because
>> the 'buf' memory maybe freed.
> 
> Huh?  What are you talking about?
>                         struct pipe_buffer *buf = &pipe->bufs[tail & mask];
> To free *buf you would need to free the entire damn array, which is
> obviously not going to be possible here; if you are talking about reuse
> of *buf - that's controlled by pipe->tail, and we do not assign it until
> later.
> 
> Fetching any fields of *buf is safe; what can get freed is buf->page, not
> buf itself.  So that buf->flags access is fine.

Right. Thank you for explaining clearly. Sorry, I misunderstood in the
course of learning.

> 
> .
> 

-- 
Regards,
  Zhen Lei

      reply	other threads:[~2022-11-25  7:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 11:53 [PATCH] pipe: fix potential use-after-free in pipe_read() Zhen Lei
2022-11-25  6:33 ` Al Viro
2022-11-25  7:52   ` Leizhen (ThunderTown) [this message]

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=3a38686c-040a-202c-2778-7670a2b3f087@huawei.com \
    --to=thunder.leizhen@huawei.com \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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.