Skip to content

exec: Control flow simplifications

Eric W. Biederman linux-fsdevel linux-security-module lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 36 repliesIn review
  2. v15 patches 30 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8exec: Teach prepare_exec_creds how exec treats uids & gidskernel/cred.c+3 -03 replies
2/8exec: Factor security_bprm_creds_for_exec out of security_bprm_set_credsfs/exec.c include/linux/binfmts.h include/linux/lsm_hook_defs.h +9 more+63 -633 replies
3/8exec: Convert security_bprm_set_creds into security_bprm_repopulate_credsfs/exec.c include/linux/binfmts.h include/linux/lsm_hook_defs.h +4 more+19 -207 replies
4/8exec: Allow load_misc_binary to call prepare_binfmt unconditionallyfs/binfmt_misc.c fs/exec.c include/linux/binfmts.h+17 -193 replies
5/8exec: Move the call of prepare_binprm into search_binary_handlerarch/alpha/kernel/binfmt_loader.c fs/binfmt_em86.c fs/binfmt_misc.c +3 more+5 -222 replies
6/8exec/binfmt_script: Don't modify bprm->buf and then return -ENOEXECfs/binfmt_script.c+38 -422 replies
7/8exec: Generic execfd supportfs/binfmt_elf.c fs/binfmt_elf_fdpic.c fs/binfmt_misc.c +2 more+32 -419 replies
8/8exec: Remove recursion from search_binary_handlerarch/alpha/kernel/binfmt_loader.c fs/binfmt_em86.c fs/binfmt_misc.c +3 more+43 -551 reply

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchCasey SchauflerKees CookJames Morris
SeriesR-b R-b
1/8R-b
2/8A-b R-b
3/8R-b
4/8R-b
5/8R-b R-b
6/8R-b
7/8R-b
8/8R-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 v2 thread

Cover letter [PATCH v2 0/8] exec: Control flow simplifications

It is hard to follow the control flow in exec.c as the code has evolved over time and something that used to work one way now works another. This set of changes attempts to address the worst of that, to remove unnecessary work and to make the code a little easier to follow.

The churn is a bit higher than the last version of this patchset, with renaming and cleaning up of comments. I have split security_bprm_set_creds into security_bprm_creds_for_exec and security_bprm_repopulate_creds. My goal was to make it clear that one hook completes its work while the other recaculates it's work each time a new interpreter is selected.

I have added a new change at the beginning to make it clear that neither security_bprm_creds_for_exec nor security_bprm_repopulate_creds needs to be implemented as prepare_exec_creds properly does the work of setting up credentials unless something special is going on.

I have made the execfd support generic and moved out of binfmt_misc so that I can remove the recursion.

I have moved reassigning bprm->file into the loop that replaces the recursion. In doing so I discovered that binfmt_misc was naughty and was returning -ENOEXEC in such a way that the search_binary_handler loop could not continue. So I added a change to remove that naughtiness.

Eric W. Biederman (8):
exec: Teach prepare_exec_creds how exec treats uids & gids
exec: Factor security_bprm_creds_for_exec out of security_bprm_set_creds
exec: Convert security_bprm_set_creds into security_bprm_repopulate_creds
exec: Allow load_misc_binary to call prepare_binfmt unconditionally
exec: Move the call of prepare_binprm into search_binary_handler exec/binfmt_script: Don't modify bprm->buf and then return -ENOEXEC
exec: Generic execfd support
exec: Remove recursion from search_binary_handler

 arch/alpha/kernel/binfmt_loader.c  | 11 +----
 fs/binfmt_elf.c                    |  4 +-
 fs/binfmt_elf_fdpic.c              |  4 +-
 fs/binfmt_em86.c                   | 13 +----
 fs/binfmt_misc.c                   | 69 ++++-----------------------
 fs/binfmt_script.c                 | 82 ++++++++++++++------------------
 fs/exec.c                          | 97 ++++++++++++++++++++++++++------------
 include/linux/binfmts.h            | 36 ++++++--------
 include/linux/lsm_hook_defs.h      |  3 +-
 include/linux/lsm_hooks.h          | 52 +++++++++++---------
 include/linux/security.h           | 14 ++++--
 kernel/cred.c                      |  3 ++
 security/apparmor/domain.c         |  7 +--
 security/apparmor/include/domain.h |  2 +-
 security/apparmor/lsm.c            |  2 +-
 security/commoncap.c               |  9 ++--
 security/security.c                |  9 +++-
 security/selinux/hooks.c           |  8 ++--
 security/smack/smack_lsm.c         |  9 ++--
 security/tomoyo/tomoyo.c           | 12 ++---
 20 files changed, 202 insertions(+), 244 deletions(-)