diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-12-06 10:24:02 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-12-19 13:25:45 -0300 |
commit | f94446c38fb3f4ad26183984c490a9590cd05282 (patch) | |
tree | 6e9ef3cea607f8bf54757a4b051ba0f79f3de6bb /elf/tst-tunables.c | |
parent | 2a969b53c0b02fed7e43473a92f219d737fd217a (diff) | |
download | glibc-f94446c38fb3f4ad26183984c490a9590cd05282.tar.gz glibc-f94446c38fb3f4ad26183984c490a9590cd05282.tar.xz glibc-f94446c38fb3f4ad26183984c490a9590cd05282.zip |
elf: Do not set invalid tunables values
The loader now warns for invalid and out-of-range tunable values. The patch also fixes the parsing of size_t maximum values, where _dl_strtoul was failing for large values close to SIZE_MAX. Checked on x86_64-linux-gnu. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'elf/tst-tunables.c')
-rw-r--r-- | elf/tst-tunables.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/elf/tst-tunables.c b/elf/tst-tunables.c index 188345b070..d6a1e1b3ac 100644 --- a/elf/tst-tunables.c +++ b/elf/tst-tunables.c @@ -53,6 +53,13 @@ static const struct test_t 4096, 0, }, + { + "GLIBC_TUNABLES", + "glibc.malloc.mmap_threshold=-1", + 0, + SIZE_MAX, + 0, + }, /* Empty tunable are ignored. */ { "GLIBC_TUNABLES", @@ -224,6 +231,29 @@ static const struct test_t 0, 0, }, + /* Invalid numbers are ignored. */ + { + "GLIBC_TUNABLES", + "glibc.malloc.check=abc:glibc.malloc.mmap_threshold=4096", + 0, + 4096, + 0, + }, + { + "GLIBC_TUNABLES", + "glibc.malloc.check=2:glibc.malloc.mmap_threshold=abc", + 2, + 0, + 0, + }, + { + "GLIBC_TUNABLES", + /* SIZE_MAX + 1 */ + "glibc.malloc.mmap_threshold=18446744073709551616", + 0, + 0, + 0, + }, /* Also check some tunable aliases. */ { "MALLOC_CHECK_", |