diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-11-22 17:43:24 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-12-05 13:21:36 -0300 |
commit | 61d848b554c8dd1f017b9d187b2a2f6675dbdbe4 (patch) | |
tree | 41de82ebf009ff82eb713b521d0a378d8ed2d11f /elf | |
parent | 876a12e51323b4c0f7b6f32ec76f4a5280b7f0b9 (diff) | |
download | glibc-61d848b554c8dd1f017b9d187b2a2f6675dbdbe4.tar glibc-61d848b554c8dd1f017b9d187b2a2f6675dbdbe4.tar.gz glibc-61d848b554c8dd1f017b9d187b2a2f6675dbdbe4.tar.bz2 glibc-61d848b554c8dd1f017b9d187b2a2f6675dbdbe4.zip |
elf: Ignore LD_BIND_NOW and LD_BIND_NOT for setuid binaries
To avoid any environment variable to change setuid binaries
semantics.
Checked on x86_64-linux-gnu.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'elf')
-rw-r--r-- | elf/rtld.c | 8 | ||||
-rw-r--r-- | elf/tst-env-setuid.c | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/elf/rtld.c b/elf/rtld.c index 55cdb4836e..d9a6c33b31 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -2604,12 +2604,14 @@ process_envvars (struct dl_main_state *state) case 8: /* Do we bind early? */ - if (memcmp (envline, "BIND_NOW", 8) == 0) + if (!__libc_enable_secure + && memcmp (envline, "BIND_NOW", 8) == 0) { GLRO(dl_lazy) = envline[9] == '\0'; break; } - if (memcmp (envline, "BIND_NOT", 8) == 0) + if (! __libc_enable_secure + && memcmp (envline, "BIND_NOT", 8) == 0) GLRO(dl_bind_not) = envline[9] != '\0'; break; @@ -2686,6 +2688,8 @@ process_envvars (struct dl_main_state *state) if (GLRO(dl_debug_mask) != 0 || GLRO(dl_verbose) != 0 + || GLRO(dl_lazy) != 1 + || GLRO(dl_bind_not) != 0 || state->mode != rtld_mode_normal || state->version_info) _exit (5); diff --git a/elf/tst-env-setuid.c b/elf/tst-env-setuid.c index b1d64ac085..9fa591a136 100644 --- a/elf/tst-env-setuid.c +++ b/elf/tst-env-setuid.c @@ -63,12 +63,12 @@ static const struct envvar_t filtered_envvars[] = { "LD_DEBUG_OUTPUT", "/tmp/some-file" }, { "LD_WARN", FILTERED_VALUE }, { "LD_VERBOSE", FILTERED_VALUE }, + { "LD_BIND_NOW", "0" }, + { "LD_BIND_NOT", "1" }, }; static const struct envvar_t unfiltered_envvars[] = { - { "LD_BIND_NOW", "0" }, - { "LD_BIND_NOT", "1" }, /* Non longer supported option. */ { "LD_ASSUME_KERNEL", UNFILTERED_VALUE }, }; |