linker: only re-open std* for setuid programs.
get_AT_SECURE() was getting called before linker_env_init() had been called, and returning the default value ("true"). This was causing us to reopen closed stdin, stdout, and stderr for ALL processes, not just privileged (setuid) processes. Calling path: - __linker_init - soinfo_link_image - get_AT_SECURE - __linker_init_post_relocation - linker_env_init This change restores the intended behavior of only re-opening stdin, stdout, and stderr for privileged processes. Change-Id: I8b085ea6597710ac4c1a3c93f1bf8b81eecb08c0
This commit is contained in:
@@ -1595,11 +1595,6 @@ static bool soinfo_link_image(soinfo* si) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a setuid/setgid program, close the security hole described in
|
|
||||||
// ftp://ftp.freebsd.org/pub/FreeBSD/CERT/advisories/FreeBSD-SA-02:23.stdio.asc
|
|
||||||
if (get_AT_SECURE()) {
|
|
||||||
nullify_closed_stdio();
|
|
||||||
}
|
|
||||||
notify_gdb_of_load(si);
|
notify_gdb_of_load(si);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1628,6 +1623,12 @@ static Elf32_Addr __linker_init_post_relocation(KernelArgumentBlock& args, Elf32
|
|||||||
// Initialize environment functions, and get to the ELF aux vectors table.
|
// Initialize environment functions, and get to the ELF aux vectors table.
|
||||||
linker_env_init(args);
|
linker_env_init(args);
|
||||||
|
|
||||||
|
// If this is a setuid/setgid program, close the security hole described in
|
||||||
|
// ftp://ftp.freebsd.org/pub/FreeBSD/CERT/advisories/FreeBSD-SA-02:23.stdio.asc
|
||||||
|
if (get_AT_SECURE()) {
|
||||||
|
nullify_closed_stdio();
|
||||||
|
}
|
||||||
|
|
||||||
debuggerd_init();
|
debuggerd_init();
|
||||||
|
|
||||||
// Get a few environment variables.
|
// Get a few environment variables.
|
||||||
|
Reference in New Issue
Block a user