History

exec: Allow load_misc_binary to call prepare_binprm unconditionally

Add a flag preserve_creds that binfmt_misc can set to prevent credentials from being updated. This allows binfmt_misc to always call prepare_binprm. Allowing the credential computation logic to be consolidated. Not replacing the credentials with the interpreters credentials is safe because because an open file descriptor to the executable is passed to the interpreter. As the interpreter does not need to reopen the executable it is guaranteed to see the same file that exec sees.

Eric W. Biederman committed 6 years ago

Commit a16b3351 parent 112b7143 files · +17 −19Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/binfmts.h+2−0
@@ -26,6 +26,8 @@ struct linux_binprm { · 25 unmodified lines
26 unsigned long p; /* current top of mem */26 unsigned long p; /* current top of mem */
27 unsigned long argmin; /* rlimit marker for copy_strings() */27 unsigned long argmin; /* rlimit marker for copy_strings() */
28 unsigned int28 unsigned int
29 /* It is safe to use the creds of a script (see binfmt_misc) */
30 preserve_creds:1,
29 /*31 /*
30 * True if most recent call to security_bprm_set_creds32 * True if most recent call to security_bprm_set_creds
31 * resulted in elevated privileges.33 * resulted in elevated privileges.