From: Charan Teja Kalla <quic_charante@quicinc.com>
To: Michal Hocko <mhocko@suse.com>
Cc: <akpm@linux-foundation.org>, <david@redhat.com>,
<quic_pkondeti@quicinc.com>, <pasha.tatashin@soleen.com>,
<sjpark@amazon.de>, <sieberf@amazon.com>, <shakeelb@google.com>,
<dhowells@redhat.com>, <willy@infradead.org>,
<minchan@kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>
Subject: Re: [PATCH V2] mm: fix use-after free of page_ext after race with memory-offline
Date: Mon, 1 Aug 2022 18:31:45 +0530 [thread overview]
Message-ID: <54e4ce7d-7cbd-480c-28ba-cba684341b37@quicinc.com> (raw)
In-Reply-To: <YueObAiml8c74DLV@dhcp22.suse.cz>
Thanks Michal !!
On 8/1/2022 1:57 PM, Michal Hocko wrote:
>> Currently not all the places where page_ext is being used is put under
>> the rcu_lock. I just used rcu lock in the places where it is possible to
>> have the use-after-free of page_ext. You recommend to use rcu lock while
>> using with page_ext in all the places?
> Yes. Using locking inconsistently just begs for future problems. There
> should be a very good reason to use lockless approach in some paths and
> that would be where the locking overhead is not really acceptable or
> when the locking cannot be used for other reasons.
>
> RCU read lock is essentially zero overhead so the only reason would be
> that the critical section would require to sleep. Is any of that the
> case?
>
> If there is a real need to have a lockless variant then I would propose
> to add __page_ext_get/put which would be lockless and clearly documented
> under which contexts it can be used and enfore those condictions (e.g.
> reference count assumption).
>
Let me try to use a single interface here.
>> The roll back operation in the online_page_ext(), where we free the
>> allocated page_ext's, will not have the PAGE_EXT_INVALID flag thus
>> WARN() may not work here. no?
> Wouldn't ms->page_ext be NULL in that case?
I don't think that ms->page_ext would be NULL here.
online_page_ext():
(a) for (pfn = start; !fail && pfn < end; pfn += PAGES_PER_SECTION)
fail = init_section_page_ext():
ms->page_ext = (void *)base - page_ext_size * pfn;
//If fail = -ERROR in the middle, roll back operation.
(b) for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION)
__free_page_ext();
Here (b) can be called on the sections without PAGE_EXT_INVALID with
ms->page_ext != NULL.
Thanks,
Charan
next prev parent reply other threads:[~2022-08-01 13:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 14:15 Charan Teja Kalla
2022-07-27 14:19 ` Charan Teja Kalla
2022-07-27 17:29 ` David Hildenbrand
2022-07-28 9:53 ` Charan Teja Kalla
2022-08-01 8:30 ` David Hildenbrand
2022-08-01 11:50 ` Charan Teja Kalla
2022-08-01 12:04 ` David Hildenbrand
2022-07-28 14:37 ` Michal Hocko
2022-07-29 15:47 ` Charan Teja Kalla
2022-08-01 8:27 ` Michal Hocko
2022-08-01 13:01 ` Charan Teja Kalla [this message]
2022-08-01 13:08 ` Michal Hocko
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=54e4ce7d-7cbd-480c-28ba-cba684341b37@quicinc.com \
--to=quic_charante@quicinc.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=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=pasha.tatashin@soleen.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