All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jinjiang Tu <tujinjiang@huawei.com>
To: Jann Horn <jannh@google.com>
Cc: <akpm@linux-foundation.org>, <david@kernel.org>, <ljs@kernel.org>,
	<lance.yang@linux.dev>, <riel@surriel.com>, <liam@infradead.org>,
	<vbabka@kernel.org>, <harry@kernel.org>, <minchan.kim@gmail.com>,
	<lwoodman@redhat.com>, <kamezawa.hiroyu@jp.fujitsu.com>,
	<linux-mm@kvack.org>, <wangkefeng.wang@huawei.com>,
	<sunnanyong@huawei.com>
Subject: Re: [PATCH v2] mm/rmap: fix missing barrier between anon_vma init and vma->anon_vma publish
Date: Thu, 10 Sep 2026 10:57:57 +0800	[thread overview]
Message-ID: <c84c5864-43ef-414f-acd2-99db78ee9358@huawei.com> (raw)
In-Reply-To: <CAG48ez29qhPAiEz2SHy2JDiOJcF2Xv8Y2prZNGxw4Q+08DyCXQ@mail.gmail.com>


在 2026/9/9 23:25, Jann Horn 写道:
> On Tue, Sep 8, 2026 at 2:57 PM Jinjiang Tu <tujinjiang@huawei.com> wrote:
>> diff --git a/mm/rmap.c b/mm/rmap.c
>> index d1819fd69938..f3b21aaa34ee 100644
>> --- a/mm/rmap.c
>> +++ b/mm/rmap.c
>> @@ -209,7 +209,11 @@ int __anon_vma_prepare(struct vm_area_struct *vma)
>>          /* page_table_lock to protect against threads */
>>          spin_lock(&mm->page_table_lock);
>>          if (likely(!vma->anon_vma)) {
>> -               vma->anon_vma = anon_vma;
>> +               /*
>> +                * Make anon_vma fields visible before anon_vma is published.
>> +                * Paired with an address dependency in reusable_anon_vma().
>> +                */
>> +               smp_store_release(&vma->anon_vma, anon_vma);
> Yes, this should go in. There are remaining theoretical issues (we
> really should also be using READ_ONCE() in places like unuse_mm(), see
> <https://lore.kernel.org/all/20230726214103.3261108-4-jannh@google.com/>),
> but this is the important fix.

Theoretically yes, but I'm curious whether these are actual problems in practice.

In hugepage_vma_revalidate() and unuse_mm(), the code only checks whether anon_vma
is non-NULL — it doesn't dereference anon_vma to access its fields.

In KSM, rmap_item->anon_vma is assigned from vma->anon_vma, and the rmap_item is
then inserted into a stable node. There is a very long time window before
rmap_walk_ksm() could ever observe it.

>


  reply	other threads:[~2026-09-10  2:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 12:29 [PATCH v2] mm/rmap: fix missing barrier between anon_vma init and vma->anon_vma publish Jinjiang Tu
2026-09-09 15:20 ` David Hildenbrand (Arm)
2026-09-09 15:25 ` Jann Horn
2026-09-10  2:57   ` Jinjiang Tu [this message]
2026-09-10  7:00 ` Vlastimil Babka (SUSE)

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=c84c5864-43ef-414f-acd2-99db78ee9358@huawei.com \
    --to=tujinjiang@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=harry@kernel.org \
    --cc=jannh@google.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=lwoodman@redhat.com \
    --cc=minchan.kim@gmail.com \
    --cc=riel@surriel.com \
    --cc=sunnanyong@huawei.com \
    --cc=vbabka@kernel.org \
    --cc=wangkefeng.wang@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.