mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
exec: Factor security_bprm_creds_for_exec out of security_bprm_set_creds
Today security_bprm_set_creds has several implementations: apparmor_bprm_set_creds, cap_bprm_set_creds, selinux_bprm_set_creds, smack_bprm_set_creds, and tomoyo_bprm_set_creds. Except for cap_bprm_set_creds they all test bprm->called_set_creds and return immediately if it is true. The function cap_bprm_set_creds ignores bprm->calld_sed_creds entirely. Create a new LSM hook security_bprm_creds_for_exec that is called just before prepare_binprm in __do_execve_file, resulting in a LSM hook that is called exactly once for the entire of exec. Modify the bits of security_bprm_set_creds that only want to be called once per exec into security_bprm_creds_for_exec, leaving only cap_bprm_set_creds behind. Remove bprm->called_set_creds all of it's former users have been moved to security_bprm_creds_for_exec. Add or upate comments a appropriate to bring them up to date and to reflect this change. Link: https://lkml.kernel.org/r/87v9kszrzh.fsf_-_@x220.int.ebiederm.org Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Acked-by: Casey Schaufler <casey@schaufler-ca.com> # For the LSM and Smack bits Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
This commit is contained in:
@@ -27,22 +27,14 @@ struct linux_binprm {
|
||||
unsigned long argmin; /* rlimit marker for copy_strings() */
|
||||
unsigned int
|
||||
/*
|
||||
* True after the bprm_set_creds hook has been called once
|
||||
* (multiple calls can be made via prepare_binprm() for
|
||||
* binfmt_script/misc).
|
||||
*/
|
||||
called_set_creds:1,
|
||||
/*
|
||||
* True if most recent call to the commoncaps bprm_set_creds
|
||||
* hook (due to multiple prepare_binprm() calls from the
|
||||
* binfmt_script/misc handlers) resulted in elevated
|
||||
* privileges.
|
||||
* True if most recent call to cap_bprm_set_creds
|
||||
* resulted in elevated privileges.
|
||||
*/
|
||||
cap_elevated:1,
|
||||
/*
|
||||
* Set by bprm_set_creds hook to indicate a privilege-gaining
|
||||
* exec has happened. Used to sanitize execution environment
|
||||
* and to set AT_SECURE auxv for glibc.
|
||||
* Set by bprm_creds_for_exec hook to indicate a
|
||||
* privilege-gaining exec has happened. Used to set
|
||||
* AT_SECURE auxv for glibc.
|
||||
*/
|
||||
secureexec:1,
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user