diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-06-09 11:34:09 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-06-09 22:34:01 +0200 |
commit | 894dad2975c61f59e71561cab21d6f85e8523b57 (patch) | |
tree | 7efc9fa8f1f8374fdaaf6393b8ceaa3270528d6e /src/test/test-seccomp.c | |
parent | Merge pull request #23348 from medhefgo/log-shutdown-blockers (diff) | |
download | systemd-894dad2975c61f59e71561cab21d6f85e8523b57.tar.xz systemd-894dad2975c61f59e71561cab21d6f85e8523b57.zip |
test: account for ADDR_NO_RANDOMIZE if it's set
On ppc64le sanitizers disable ASLR (i.e. by setting ADDR_NO_RANDOMIZE),
which opinionated_personality() doesn't return. Let's tweak the current
personality ourselves in such cases.
See: https://github.com/llvm/llvm-project/commit/78f7a6eaa601bfdd6ae70ffd3da2254c21ff77f9
Resolves: #23666
Diffstat (limited to '')
-rw-r--r-- | src/test/test-seccomp.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c index 45fe8f7c59..db7c217521 100644 --- a/src/test/test-seccomp.c +++ b/src/test/test-seccomp.c @@ -934,8 +934,15 @@ TEST(lock_personality) { } assert_se(opinionated_personality(¤t) >= 0); + /* On ppc64le sanitizers disable ASLR (i.e. by setting ADDR_NO_RANDOMIZE), + * which opinionated_personality() doesn't return. Let's tweak the current + * personality ourselves in such cases. + * See: https://github.com/llvm/llvm-project/commit/78f7a6eaa601bfdd6ae70ffd3da2254c21ff77f9 + */ + if (FLAGS_SET(safe_personality(PERSONALITY_INVALID), ADDR_NO_RANDOMIZE)) + current |= ADDR_NO_RANDOMIZE; - log_info("current personality=%lu", current); + log_info("current personality=0x%lX", current); pid = fork(); assert_se(pid >= 0); @@ -945,13 +952,14 @@ TEST(lock_personality) { assert_se((unsigned long) safe_personality(current) == current); - /* Note, we also test that safe_personality() works correctly, by checkig whether errno is properly + /* Note, we also test that safe_personality() works correctly, by checking whether errno is properly * set, in addition to the return value */ errno = 0; - assert_se(safe_personality(PER_LINUX | ADDR_NO_RANDOMIZE) == -EPERM); + assert_se(safe_personality(PER_LINUX | MMAP_PAGE_ZERO) == -EPERM); assert_se(errno == EPERM); - assert_se(safe_personality(PER_LINUX | MMAP_PAGE_ZERO) == -EPERM); + if (!FLAGS_SET(current, ADDR_NO_RANDOMIZE)) + assert_se(safe_personality(PER_LINUX | ADDR_NO_RANDOMIZE) == -EPERM); assert_se(safe_personality(PER_LINUX | ADDR_COMPAT_LAYOUT) == -EPERM); assert_se(safe_personality(PER_LINUX | READ_IMPLIES_EXEC) == -EPERM); assert_se(safe_personality(PER_LINUX_32BIT) == -EPERM); |