Re: [PATCH 3/4] mm: synchronize saved_auxv access with arg_lock
Andrei Vagin <[email protected]> Tue, 10 Feb 2026 17:08:46 -0800
| Newsgroups | dev.linux.lists.criu,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <CAEWA0a6x+RfcBpOrcJuWaFcZCPAbBV2uDWHfQbaCMv8vBHeZEg@mail.gmail.com> |
On Tue, Feb 10, 2026 at 12:36 PM Alexander Mikhalitsyn <[email protected]> wrote: > .... > > static const struct file_operations proc_auxv_operations = { > > diff --git a/kernel/fork.c b/kernel/fork.c > > index 0091315643de..c0a3dd94df22 100644 > > --- a/kernel/fork.c > > +++ b/kernel/fork.c > > @@ -1104,8 +1104,13 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, > > __mm_flags_overwrite_word(mm, mmf_init_legacy_flags(flags)); > > mm->def_flags = current->mm->def_flags & VM_INIT_DEF_MASK; > > > > - if (mm_flags_test(MMF_USER_HWCAP, current->mm)) > > + if (mm_flags_test(MMF_USER_HWCAP, current->mm)) { > > + spin_lock(¤t->mm->arg_lock); > > mm_flags_set(MMF_USER_HWCAP, mm); > > + memcpy(mm->saved_auxv, current->mm->saved_auxv, > > + sizeof(mm->saved_auxv)); > > nit: I was looking for this memcpy(mm->saved_auxv, > current->mm->saved_auxv, sizeof(mm->saved_auxv)) while reviewing > a previous patch. Shouldn't it be there? > No, it should not. dup_mm copies the contents of the old mm to the new one immediately after allocation, but it does so without holding any locks. Thanks, Andrei