lkml.org 
[lkml]   [2022]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V3] mm: fix use-after free of page_ext after race with memory-offline
On Tue 16-08-22 15:04:01, Charan Teja Kalla wrote:
[...]
> >> @@ -183,19 +184,26 @@ static inline void __set_page_owner_handle(struct page_ext *page_ext,
> >> noinline void __set_page_owner(struct page *page, unsigned short order,
> >> gfp_t gfp_mask)
> >> {
> >> - struct page_ext *page_ext = lookup_page_ext(page);
> >> + struct page_ext *page_ext = page_ext_get(page);
> >> depot_stack_handle_t handle;
> >>
> >> if (unlikely(!page_ext))
> >> return;
> > Either add a comment like this
> > /* save_stack can sleep in general so we have to page_ext_put */
>
>
> Vlastimil suggested to go for save stack first since !page_ext is mostly
> unlikely. Snip from his comments:
> Why not simply do the save_stack() first and then page_ext_get() just
> once? It should be really rare that it's NULL, so I don't think we save
> much by avoiding an unnecessary save_stack(), while the overhead of
> doing two get/put instead of one will affect every call.

right see below
>
> https://lore.kernel.org/all/f5fd4942-b03e-1d1c-213b-9cd5283ced91@suse.cz/
> >> + page_ext_put();
> >>
> >> handle = save_stack(gfp_mask);
> > or just drop the initial page_ext_get altogether. This function is
> > called only when page_ext is supposed to be initialized and !page_ext
> > case above should be very unlikely. Or is there any reason to keep this?

^^^^^
--
Michal Hocko
SUSE Labs

\
 
 \ /
  Last update: 2022-08-16 18:16    [W:0.058 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site