mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bradley Morgan <bradley.morgan@linux.dev>
To: m.harisawan@icloud.com
Cc: akpm@linux-foundation.org, bsegall@google.com, david@kernel.org,
	dietmar.eggemann@arm.com, juri.lelli@redhat.com, kees@kernel.org,
	kprateek.nayak@amd.com, liam@infradead.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org, ljs@kernel.org,
	mgorman@suse.de, mhocko@suse.com, mingo@redhat.com,
	peterz@infradead.org, rostedt@goodmis.org, rppt@kernel.org,
	surenb@google.com, syzkaller-bugs@googlegroups.com,
	vbabka@kernel.org, vincent.guittot@linaro.org,
	vschneid@redhat.com
Subject: Re: [PATCH] fork: mark memcpy() in dup_mm() with data_race()
Date: Tue, 17 Nov 2026 16:23:26 +0000	[thread overview]
Message-ID: <CAEA6A30-B69D-460C-B5A7-057F2BC6A52E@linux.dev> (raw)
In-Reply-To: <179489519663.1444496.15875846661591982934@icloud.com>

On 17 November 2026 05:59:56 GMT, Muhammad Haris Awan
<m.harisawan@icloud.com> wrote:
>KCSAN reported a data race between dup_mm() copying oldmm via
>memcpy(mm, oldmm, sizeof(*mm)) and lru_gen_del_mm() modifying
>oldmm->lru_gen.list when an adjacent mm_struct on the shared
>mm_list->fifo is removed under mm_list->lock.
>
>oldmm->lru_gen and oldmm->mmlist are protected by mm_list->lock /
>mmlist_lock (or updated locklessly via lru_gen_use_mm()), not
>oldmm->mmap_lock. Because struct mm_struct uses __randomize_layout and
>mm_init() immediately reinitializes these fields on the new mm, wrap
>the memcpy() in data_race(), matching dup_vma() in mm/vma_init.c.
>
>Fixes: bd74fdaea146 ("mm: multi-gen LRU: support page table walks")
>Reported-by: syzbot+c6e1b1b32ff2fc3b7d60@syzkaller.appspotmail.com
>Closes: https://syzkaller.appspot.com/bug?extid=c6e1b1b32ff2fc3b7d60
>Signed-off-by: Muhammad Haris Awan <m.harisawan@icloud.com>
>---
> kernel/fork.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
>diff --git a/kernel/fork.c b/kernel/fork.c
>index 5efceb8d5..14ac9a070 100644
>--- a/kernel/fork.c
>+++ b/kernel/fork.c
>@@ -1539,7 +1539,12 @@ static struct mm_struct *dup_mm(struct task_struct *tsk,
> 		goto fail_uprobe;
> 	}
> 
>-	memcpy(mm, oldmm, sizeof(*mm));
>+	/*
>+	 * oldmm->lru_gen and oldmm->mmlist may be modified concurrently under
>+	 * mm_list->lock / mmlist_lock or locklessly via lru_gen_use_mm(),
>+	 * and mm_init() will immediately reinitialize them.
>+	 */
>+	data_race(memcpy(mm, oldmm, sizeof(*mm)));

NAK. Your basically just ignoring the race, in fork, like Lorenzo said.

Let's fix this somewhere else?

> 
> 	if (!mm_init(mm, tsk)) {
> 		mmap_write_unlock(oldmm);
>

--- Thanks!

      parent reply	other threads:[~2026-11-17 16:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  5:59 Muhammad Haris Awan
2026-11-17  8:59 ` David Hildenbrand (Arm)
2026-11-17 10:24   ` Muhammad Haris Awan
2026-11-17 10:54     ` David Hildenbrand (Arm)
2026-11-17 13:02       ` Lorenzo Stoakes (ARM)
2026-11-17 14:26         ` Muhammad Haris Awan
2026-11-17 12:58 ` Lorenzo Stoakes (ARM)
2026-11-17 16:23 ` Bradley Morgan [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=CAEA6A30-B69D-460C-B5A7-057F2BC6A52E@linux.dev \
    --to=bradley.morgan@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=bsegall@google.com \
    --cc=david@kernel.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kees@kernel.org \
    --cc=kprateek.nayak@amd.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=m.harisawan@icloud.com \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=vbabka@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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 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®