From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
Pedro Falcato <pfalcato@suse.de>, Kees Cook <kees@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Suren Baghdasaryan <surenb@google.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] mm: abstract initial stack setup to mm subsystem
Date: Fri, 25 Apr 2025 11:11:18 +0100 [thread overview]
Message-ID: <beee409d-67d7-4754-91af-99b4e193ece2@lucifer.local> (raw)
In-Reply-To: <57e543a2-4c5a-445e-a3ab-affbea337d93@redhat.com>
On Thu, Apr 24, 2025 at 11:30:35PM +0200, David Hildenbrand wrote:
> On 24.04.25 23:15, Lorenzo Stoakes wrote:
> > There are peculiarities within the kernel where what is very clearly mm
> > code is performed elsewhere arbitrarily.
> >
> > This violates separation of concerns and makes it harder to refactor code
> > to make changes to how fundamental initialisation and operation of mm logic
> > is performed.
> >
> > One such case is the creation of the VMA containing the initial stack upon
> > execve()'ing a new process. This is currently performed in __bprm_mm_init()
> > in fs/exec.c.
> >
> > Abstract this operation to create_init_stack_vma(). This allows us to limit
> > use of vma allocation and free code to fork and mm only.
> >
> > We previously did the same for the step at which we relocate the initial
> > stack VMA downwards via relocate_vma_down(), now we move the initial VMA
> > establishment too.
> >
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> > ---
> ...
>
> > +/*
> > + * Establish the stack VMA in an execve'd process, located temporarily at the
> > + * maximum stack address provided by the architecture.
> > + *
> > + * We later relocate this downwards in relocate_vma_down().
> > + *
> > + * This function is almost certainly NOT what you want for anything other than
> > + * early executable initialisation.
> > + *
> > + * On success, returns 0 and sets *vmap to the stack VMA and *top_mem_p to the
> > + * maximum addressable location in the stack (that is capable of storing a
> > + * system word of data).
> > + *
> > + * on failure, returns an error code.
> > + */
>
> I was about to say, if you already write that much documentation, why not
> turn it into kerneldoc? :) But this function is clearly not intended to have
> more than one caller, so ... :)
Haha yeah, I felt for this case it's probably not necessary, bit of a blurry
line on this but as a one-off thing probably ok :P
>
> Acked-by: David Hildenbrand <david@redhat.com>
Thanks! Sorry I forgot to say thanks also to Suren for his tag in other email,
so will say here - also thanks Suren :)
>
> --
> Cheers,
>
> David / dhildenb
>
next prev parent reply other threads:[~2025-04-25 10:11 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 21:15 [PATCH 0/4] move all VMA allocation, freeing and duplication logic to mm Lorenzo Stoakes
2025-04-24 21:15 ` [PATCH 1/4] mm: abstract initial stack setup to mm subsystem Lorenzo Stoakes
2025-04-24 21:30 ` David Hildenbrand
2025-04-25 0:55 ` Suren Baghdasaryan
2025-04-25 10:10 ` Lorenzo Stoakes
2025-04-25 10:11 ` Lorenzo Stoakes [this message]
2025-04-24 21:15 ` [PATCH 2/4] mm: perform VMA allocation, freeing, duplication in mm Lorenzo Stoakes
2025-04-24 21:22 ` David Hildenbrand
2025-04-25 1:22 ` Suren Baghdasaryan
2025-04-25 1:37 ` Suren Baghdasaryan
2025-04-25 10:10 ` Lorenzo Stoakes
2025-04-25 11:04 ` Lorenzo Stoakes
2025-04-25 10:09 ` Lorenzo Stoakes
2025-04-25 10:26 ` Liam R. Howlett
2025-04-25 10:31 ` Lorenzo Stoakes
2025-04-25 10:45 ` Lorenzo Stoakes
2025-04-25 11:00 ` Liam R. Howlett
2025-04-25 11:03 ` Lorenzo Stoakes
2025-04-25 10:17 ` Lorenzo Stoakes
2025-04-25 3:15 ` Kees Cook
2025-04-25 10:40 ` Lorenzo Stoakes
2025-04-25 10:53 ` Pedro Falcato
2025-04-25 13:54 ` Liam R. Howlett
2025-04-25 15:32 ` Suren Baghdasaryan
2025-04-25 15:34 ` Suren Baghdasaryan
2025-04-25 17:12 ` Kees Cook
2025-04-25 17:26 ` Suren Baghdasaryan
2025-04-24 21:15 ` [PATCH 3/4] mm: move dup_mmap() to mm Lorenzo Stoakes
2025-04-25 9:13 ` Pedro Falcato
2025-04-25 10:18 ` Lorenzo Stoakes
2025-04-24 21:15 ` [PATCH 4/4] mm: move vm_area_alloc,dup,free() functions to vma.c Lorenzo Stoakes
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=beee409d-67d7-4754-91af-99b4e193ece2@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=david@redhat.com \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pfalcato@suse.de \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=viro@zeniv.linux.org.uk \
/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