[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YvplthTjM8Ez5DIq@casper.infradead.org>
Date: Mon, 15 Aug 2022 16:26:46 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Michal Hocko <mhocko@...e.com>
Cc: Charan Teja Kalla <quic_charante@...cinc.com>,
akpm@...ux-foundation.org, david@...hat.com,
pasha.tatashin@...een.com, sieberf@...zon.com, shakeelb@...gle.com,
sjpark@...zon.de, dhowells@...hat.com, quic_pkondeti@...cinc.com,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH V3] mm: fix use-after free of page_ext after race with
memory-offline
On Mon, Aug 15, 2022 at 05:06:18PM +0200, Michal Hocko wrote:
> > + * This function gives proper page_ext of a memory section
> > + * during race with the offline operation on a memory block
> > + * this section falls into. Not using this function to get
> > + * page_ext of a page, in code paths where extra refcount
> > + * is not taken on that page eg: pfn walking, can lead to
> > + * use-after-free access of page_ext.
>
> I do not think this is really useful comment, it goes into way too much
> detail about memory hotplug yet not enough to actually understand the
> interaction because there are no references to the actual
> synchronization scheme. I would go with something like:
>
> /*
> * Get a page_ext associated with the given page. Returns NULL if
> * no such page_ext exists otherwise ensures that the page_ext will
> * stay alive until page_ext_put is called.
> * This implies a non-sleeping context.
> */
I'd go further and turn this into kernel-doc:
/**
* page_ext_get() - Get the extended information for a page.
* @page: The page we're interested in.
*
* Ensures that the page_ext will remain valid until page_ext_put()
* is called.
*
* Return: NULL if no page_ext exists for this page.
* Context: Any context. Caller may not sleep until they have called
* page_ext_put().
*/
Powered by blists - more mailing lists