[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3a38686c-040a-202c-2778-7670a2b3f087@huawei.com>
Date: Fri, 25 Nov 2022 15:52:53 +0800
From: "Leizhen (ThunderTown)" <thunder.leizhen@...wei.com>
To: Al Viro <viro@...iv.linux.org.uk>
CC: Matthew Wilcox <willy@...radead.org>,
<linux-fsdevel@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
David Howells <dhowells@...hat.com>
Subject: Re: [PATCH] pipe: fix potential use-after-free in pipe_read()
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
Powered by blists - more mailing lists