mirror of
https://github.com/systemd/systemd.git
synced 2024-10-29 21:55:36 +03:00
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: 78f7a6eaa6
Resolves: #23666
This commit is contained in:
parent
677ec2d609
commit
894dad2975
@ -934,8 +934,15 @@ TEST(lock_personality) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert_se(opinionated_personality(¤t) >= 0);
|
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();
|
pid = fork();
|
||||||
assert_se(pid >= 0);
|
assert_se(pid >= 0);
|
||||||
@ -945,13 +952,14 @@ TEST(lock_personality) {
|
|||||||
|
|
||||||
assert_se((unsigned long) safe_personality(current) == current);
|
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 */
|
* set, in addition to the return value */
|
||||||
errno = 0;
|
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(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 | ADDR_COMPAT_LAYOUT) == -EPERM);
|
||||||
assert_se(safe_personality(PER_LINUX | READ_IMPLIES_EXEC) == -EPERM);
|
assert_se(safe_personality(PER_LINUX | READ_IMPLIES_EXEC) == -EPERM);
|
||||||
assert_se(safe_personality(PER_LINUX_32BIT) == -EPERM);
|
assert_se(safe_personality(PER_LINUX_32BIT) == -EPERM);
|
||||||
|
Loading…
Reference in New Issue
Block a user