am 7e6a5773
: Merge "Use the AT_SECURE auxv flag to determine whether to enable secure mode."
* commit '7e6a5773133e4b65d678535418b1f5d594859da2': Use the AT_SECURE auxv flag to determine whether to enable secure mode.
This commit is contained in:
commit
5b44655f22
1 changed files with 15 additions and 4 deletions
|
@ -2085,7 +2085,7 @@ unsigned __linker_init(unsigned **elfdata)
|
|||
|
||||
int argc = (int) *elfdata;
|
||||
char **argv = (char**) (elfdata + 1);
|
||||
unsigned *vecs = (unsigned*) (argv + argc + 1);
|
||||
unsigned *vecs = (unsigned*) (argv + argc + 1), *v;
|
||||
soinfo *si;
|
||||
struct link_map * map;
|
||||
const char *ldpath_env = NULL;
|
||||
|
@ -2113,12 +2113,23 @@ unsigned __linker_init(unsigned **elfdata)
|
|||
*/
|
||||
__tls_area[TLS_SLOT_BIONIC_PREINIT] = elfdata;
|
||||
|
||||
/* Are we setuid? */
|
||||
program_is_setuid = (getuid() != geteuid()) || (getgid() != getegid());
|
||||
|
||||
/* Initialize environment functions, and get to the ELF aux vectors table */
|
||||
vecs = linker_env_init(vecs);
|
||||
|
||||
/* Check auxv for AT_SECURE first to see if program is setuid, setgid,
|
||||
has file caps, or caused a SELinux/AppArmor domain transition. */
|
||||
for (v = vecs; v[0]; v += 2) {
|
||||
if (v[0] == AT_SECURE) {
|
||||
/* kernel told us whether to enable secure mode */
|
||||
program_is_setuid = v[1];
|
||||
goto sanitize;
|
||||
}
|
||||
}
|
||||
|
||||
/* Kernel did not provide AT_SECURE - fall back on legacy test. */
|
||||
program_is_setuid = (getuid() != geteuid()) || (getgid() != getegid());
|
||||
|
||||
sanitize:
|
||||
/* Sanitize environment if we're loading a setuid program */
|
||||
if (program_is_setuid)
|
||||
linker_env_secure();
|
||||
|
|
Loading…
Reference in a new issue