From: Miaohe Lin <linmiaohe@huawei.com>
To: Linux-MM <linux-mm@kvack.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [Question] Is there a race window between __anon_vma_prepare() with page_lock_anon_vma_read() ?
Date: Wed, 19 May 2021 16:41:45 +0800 [thread overview]
Message-ID: <6da23315-a00e-4b30-68f4-828b2f66dd47@huawei.com> (raw)
In-Reply-To: <726b53ca-f8a5-c8cb-d704-bcd656afa68e@huawei.com>
On 2021/5/14 17:16, Miaohe Lin wrote:
> Hi all,
> I am investigating the rmap code, and I found the below possible race window:
>
> CPU 1 CPU 2
> ----- -----
> page_lock_anon_vma_read
> rcu_read_lock
> /* We assume anon_vam == root_anon_vma in this case. */
> root_anon_vma = READ_ONCE(anon_vma->root);
> root_anon_vma is *released* somewhere unfortunately.
> down_read_trylock(&root_anon_vma->rwsem)
> __anon_vma_prepare
> anon_vma_alloc
> root_anon_vma is *allocated* here.
> init_rwsem(&anon_vma->rwsem);
> !page_mapped(page)
> up_read(&root_anon_vma->rwsem); -- *Oops!*
>
> root_anon_vma->rwsem is reinitialized after locked. And reinitialized anon_vma->rwsem will be
> unlocked without lock first.
>
> I think this could happen due to the subtle SLAB_TYPESAFE_BY_RCU. But only can occur when anon_vma
> is root anon_vma or they won't operate on the same rwsem.
> Is this will really happen or Am I miss something ? Any reply would be very grateful.
> Many Thanks! :)
Any reply would be very grateful.
Many thanks!
>
prev parent reply other threads:[~2021-05-19 8:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 9:16 [Question] Is there a race window between __anon_vma_prepare() with page_lock_anon_vma_read() ? Miaohe Lin
2021-05-19 8:41 ` Miaohe Lin [this message]
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=6da23315-a00e-4b30-68f4-828b2f66dd47@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).