Re: [PATCH 6/7] exec: Move most of setup_new_exec into flush_old_exec

From: Kees Cook
Date: Fri May 08 2020 - 01:51:04 EST


On Thu, May 07, 2020 at 04:51:13PM -0500, Eric W. Biederman wrote:
> I intend to the following text to the changelog. At this point I
> believe I have read through everything and nothing raises any concerns
> for me:
>
> --- text begin ---
>
> To see why it is safe to move this code please note that effectively
> this change moves the personality setting in the binfmt and the following
> three lines of code after everything except unlocking the mutexes:
> arch_pick_mmap_layout
> arch_setup_new_exec
> mm->task_size = TASK_SIZE
>
> The function arch_pick_mmap_layout at most sets:
> mm->get_unmapped_area
> mm->mmap_base
> mm->mmap_legacy_base
> mm->mmap_compat_base
> mm->mmap_compat_legacy_base
> which nothing in flush_old_exec or setup_new_exec depends on.
>
> The function arch_setup_new_exec only sets architecture specific
> state and the rest of the functions only deal in state that applies
> to all architectures.
>
> The last line just sets mm->task_size and again nothing in flush_old_exec
> or setup_new_exec depend on task_size.
>
> --- text end ---
> [...]
> > So, with a bit larger changelog discussing what's moving "earlier",
> > I think this looks good:
>
> Please see above.

Awesome! Thanks for checking my checking of your checking. ;)

Acked-by: Kees Cook <keescook@xxxxxxxxxxxx>

--
Kees Cook