Skip to content

Commit 87b047d

Browse files
committed
exec: Teach prepare_exec_creds how exec treats uids & gids
It is almost possible to use the result of prepare_exec_creds with no modifications during exec. Update prepare_exec_creds to initialize the suid and the fsuid to the euid, and the sgid and the fsgid to the egid. This is all that is needed to handle the common case of exec when nothing special like a setuid exec is happening. That this preserves the existing behavior of exec can be verified by examing bprm_fill_uid and cap_bprm_set_creds. This change makes it clear that the later parts of exec that update bprm->cred are just need to handle special cases such as setuid exec and change of domains. Link: https://lkml.kernel.org/r/[email protected] Acked-by: Linus Torvalds <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent b127c16 commit 87b047d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/cred.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ struct cred *prepare_exec_creds(void)
315315
new->process_keyring = NULL;
316316
#endif
317317

318+
new->suid = new->fsuid = new->euid;
319+
new->sgid = new->fsgid = new->egid;
320+
318321
return new;
319322
}
320323

0 commit comments

Comments
 (0)