From: Al Viro <viro@zeniv.linux.org.uk>
To: Zhen Lei <thunder.leizhen@huawei.com>
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 06:33:53 +0000 [thread overview]
Message-ID: <Y4Bh0fTf4vZ6/6Pc@ZenIV> (raw)
In-Reply-To: <20221117115323.1718-1-thunder.leizhen@huawei.com>
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.
next prev parent reply other threads:[~2022-11-25 6:34 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 [this message]
2022-11-25 7:52 ` Leizhen (ThunderTown)
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=Y4Bh0fTf4vZ6/6Pc@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thunder.leizhen@huawei.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox