Skip to content

Implementing kernel_execve

Eric W. Biederman linux-fsdevel linux-security-module lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 22 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7exec: Remove unnecessary spaces from binfmts.hinclude/linux/binfmts.h+5 -52 replies
2/7exec: Factor out alloc_bprmfs/exec.c+19 -102 replies
3/7exec: Move initialization of bprm->filename into alloc_bprmfs/exec.c include/linux/binfmts.h+34 -282 replies
4/7exec: Move bprm_mm_init into alloc_bprmfs/exec.c+8 -82 replies
5/7exec: Factor bprm_execve out of do_execve_commonfs/exec.c+58 -502 replies
6/7exec: Factor bprm_stack_limits out of prepare_arg_pagesfs/exec.c+12 -112 replies
7/7exec: Implement kernel_execvearch/x86/entry/entry_32.S arch/x86/entry/entry_64.S arch/x86/kernel/unwind_frame.c +7 more+100 -239 replies

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

Patchhttps://lkml.kernel.org/r/[email protected]Kees CookChristoph Hellwig
1/7R-b R-b
2/7R-b
3/7R-b R-b
4/7R-b R-b
5/7R-b R-b
6/7R-b R-b
7/7Inspired-by R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/7] Implementing kernel_execve

This set of changes implements kernel_execve to remove the need for kernel threads to pass in pointers to in-kernel data structures
to functions that take __user pointers. Which is part of the
greater removal of set_fs work.

This set of changes makes do_execve static and so I have updated the comments. This affects the comments in the x86 entry point code and the comments in tomoyo. I believe I have updated them correctly. If not please let me know.

I have moved the calls of copy_strings before the call of security_bprm_creds_for_exec. Which might be of interest to the security folks. I can't see that it matters but I have copied the security folks just to be certain.

By moving the initialization of the new stack that copy_strings does earlier it becomes possible to copy all of the parameters to exec before anything else is done which makes it possible to have one function kernel_execve that uncondtionally handles copying parameters from kernel space, and another function do_execveat_common which handles copying parameters from userspace.

This work was inspired by Christoph Hellwig's similar patchset, which my earlier work to remove the file parameter to do_execveat_common conflicted with.
https://lore.kernel.org/linux-fsdevel/[email protected]/

I figured that after causing all of that trouble for the set_fs work the least I could do is implement the change myself.

The big practical change from Christoph's work is that he did not separate out the copying of parameters from the rest of the work of exec, which did not help the maintainability of the code.

Please let me know if you see something wrong.

This set of changes is against my exec-next branch:
https://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git exec-next

Eric W. Biederman (7):
exec: Remove unnecessary spaces from binfmts.h
exec: Factor out alloc_bprm
exec: Move initialization of bprm->filename into alloc_bprm
exec: Move bprm_mm_init into alloc_bprm
exec: Factor bprm_execve out of do_execve_common
exec: Factor bprm_stack_limits out of prepare_arg_pages
exec: Implement kernel_execve

 arch/x86/entry/entry_32.S      |   2 +-
 arch/x86/entry/entry_64.S      |   2 +-
 arch/x86/kernel/unwind_frame.c |   2 +-
 fs/exec.c                      | 301 ++++++++++++++++++++++++++++-------------
 include/linux/binfmts.h        |  20 ++-
 init/main.c                    |   4 +-
 kernel/umh.c                   |   6 +-
 security/tomoyo/common.h       |   2 +-
 security/tomoyo/domain.c       |   4 +-
 security/tomoyo/tomoyo.c       |   4 +-
 10 files changed, 224 insertions(+), 123 deletions(-)

Eric