Skip to content

Commit

Permalink
exec: clarify reasoning for euid/egid reset
Browse files Browse the repository at this point in the history
This section of code initially looks redundant, but is required. This
improves the comment to explain more clearly why the reset is needed.

Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Kees Cook authored and Linus Torvalds committed May 17, 2016
1 parent 7f427d3 commit cb6fd68
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,12 @@ static void bprm_fill_uid(struct linux_binprm *bprm)
kuid_t uid;
kgid_t gid;

/* clear any previous set[ug]id data from a previous binary */
/*
* Since this can be called multiple times (via prepare_binprm),
* we must clear any previous work done when setting set[ug]id
* bits from any earlier bprm->file uses (for example when run
* first for a setuid script then again for its interpreter).
*/
bprm->cred->euid = current_euid();
bprm->cred->egid = current_egid();

Expand Down

0 comments on commit cb6fd68

Please sign in to comment.