]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/test/test-seccomp.c
process-util: use only the least significant byte from personality()
authorFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 7 Feb 2024 18:07:07 +0000 (19:07 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 7 Feb 2024 18:29:53 +0000 (19:29 +0100)
commit3dc51ab2cf228d40438580b24082dbcf1299050c
treed0e88a24936b356c839262f2357402a7610a55da
parentd44934f3785ad9ca4aab757beb80a9b11ba4bc04
process-util: use only the least significant byte from personality()

The personality() syscall returns a 32-bit value where the top three
bytes are reserved for flags that emulate historical or architectural
quirks, and only the least significant byte reflects the actual
personality we're interested in (in opinionated_personality()).

Use the newly defined mask in the corresponding test as well, otherwise
the test fails on some more "exotic" architectures that set some of the
"quirk" flags:

~# uname -m
armv7l
~# build/test-seccomp
...
/* test_lock_personality */
current personality=0x0
safe_personality(PERSONALITY_INVALID)=0x800000
Assertion '(unsigned long) safe_personality(current) == current' failed at src/test/test-seccomp.c:970, function test_lock_personality(). Aborting.
lockpersonalityseccomp terminated by signal ABRT.
Assertion 'wait_for_terminate_and_check("lockpersonalityseccomp", pid, WAIT_LOG) == EXIT_SUCCESS' failed at src/test/test-seccomp.c:996, function test_lock_personality(). Aborting.
Aborted (core dumped)

See: personality(2) and comments in sys/personality.h
src/basic/process-util.c
src/basic/process-util.h
src/test/test-seccomp.c