mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Charan Teja Kalla <quic_charante@quicinc.com>
Cc: akpm@linux-foundation.org, david@redhat.com,
	pasha.tatashin@soleen.com, sieberf@amazon.com,
	shakeelb@google.com, sjpark@amazon.de, dhowells@redhat.com,
	willy@infradead.org, quic_pkondeti@quicinc.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH V3] mm: fix use-after free of page_ext after race with memory-offline
Date: Tue, 16 Aug 2022 18:15:33 +0200	[thread overview]
Message-ID: <YvvCpW0ep9N8CbDr@dhcp22.suse.cz> (raw)
In-Reply-To: <286e47e7-3d63-133c-aa6c-05100b557d42@quicinc.com>

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

  reply	other threads:[~2022-08-16 16:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-09 14:46 Charan Teja Kalla
2022-08-10  1:57 ` Andrew Morton
2022-08-10  7:23   ` Michal Hocko
2022-08-10  8:27     ` Charan Teja Kalla
2022-08-10 11:40 ` Vlastimil Babka
2022-08-10 14:31   ` Charan Teja Kalla
2022-08-15 15:06 ` Michal Hocko
2022-08-15 15:26   ` Matthew Wilcox
2022-08-15 15:31     ` Michal Hocko
2022-08-16  9:34   ` Charan Teja Kalla
2022-08-16 16:15     ` Michal Hocko [this message]
2022-08-18 14:01       ` Charan Teja Kalla

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=YvvCpW0ep9N8CbDr@dhcp22.suse.cz \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=quic_charante@quicinc.com \
    --cc=quic_pkondeti@quicinc.com \
    --cc=shakeelb@google.com \
    --cc=sieberf@amazon.com \
    --cc=sjpark@amazon.de \
    --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

all inboxes | Powered by JetHome®