Re: [PATCH 3/4] mm: synchronize saved_auxv access with arg_lock

Andrei Vagin
2026-02-11T01:09:01Z

On Tue, Feb 10, 2026 at 12:36 PM Alexander Mikhalitsyn
<alexander@mihalicyn.com> 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(&current->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