Re: [PATCH RFC 2/2] mm, madvise: move prctl_set_vma() to mm/madvise.c

From: Lorenzo Stoakes
Date: Mon Jun 23 2025 - 12:58:58 EST


On Mon, Jun 23, 2025 at 09:47:49AM -0700, Suren Baghdasaryan wrote:
> > -static int prctl_set_vma(unsigned long opt, unsigned long addr,
> > - unsigned long size, unsigned long arg)
> > -{
> > - struct mm_struct *mm = current->mm;
> > - const char __user *uname;
> > - struct anon_vma_name *anon_name = NULL;
> > - int error;
> > -
> > - switch (opt) {
> > - case PR_SET_VMA_ANON_NAME:
> > - uname = (const char __user *)arg;
>
> My issue with this refactoring is that prctl_set_vma() might grow some
> other opt which does not belong in madvise.c. Moving it into vma.c
> seems a bit more appropriate IMHO.

And this itself is an argument against the horror show that is prctl()...! :)

Anyway we'd have to find a way to abstract past this, since vma.c is
inaccessible to anything outside of mm.

This is part of the reason I so _hate_ prctl() - we do mm stuff there, in a
place that shouldn't...

I'll reply to patch directly as I have thoughts here though