Re: [PATCH RFC 2/2] mm, madvise: move prctl_set_vma() to mm/madvise.c
From: Lorenzo Stoakes
Date: Tue Jun 24 2025 - 04:52:43 EST
On Tue, Jun 24, 2025 at 10:12:20AM +0200, Vlastimil Babka wrote:
> On 6/23/25 19:13, Lorenzo Stoakes wrote:
> >> +{
> >> + 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:
> >
> > So I'd like to copy just the below over to madvise - we can decide to move stuff
> > around _later_ since it's really weird to have all the anon_vma_name stuff live
> > in madvise (apart from the stuff in include/linux/mm-inline.h obv) - but I think
> > that can be a follow-up patch.
>
> Sounds good, will try to come up with a name for that function then :)
I'd say set_anon_vma_name() is best, there's no need to mention that it's
madvise as y'know that's an mm internall and weird impl deail.
Also I guess we can keep madvise_set_anon_name() the same, even though
it'll be static now as it's in line with the weird convention of prefixing
things with madvise_ even though they're in madvise.c so, y'know, kinda
implied that they're related to madvise haha
>
> > I'd like to then split out bits and pieces to make this less yucky too.
> >
> > Maybe add anon_vma_name_from_user() grabbing the characters, doing the
> > strndup_user() etc., have it call a new anon_vma_name_validate() static function
> > which does the is_valid_name_char() check against all chars, etc.
>
> Right, I'm fine leaving the followup cleanups to someone else again. My
> biggest bother was patch 1 anyway :)
Yeah of course, incremental steps are valuable here, makes the next
person's life easier :)
>
> Thanks!
>
Thanks for doing this cleanup it's a big improvement!
Cheers, Lorenzo