mirror of
https://github.com/systemd/systemd
synced 2024-10-15 20:45:09 +00:00
Merge pull request #17709 from yuwata/test-seccomp-skip
test: skip several tests in test-seccomp when running under valgrind or ASAN
This commit is contained in:
commit
35ad7113db
|
@ -10,6 +10,9 @@
|
|||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#if HAVE_VALGRIND_VALGRIND_H
|
||||
#include <valgrind/valgrind.h>
|
||||
#endif
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "fd-util.h"
|
||||
|
@ -115,6 +118,21 @@ static void test_filter_sets(void) {
|
|||
for (unsigned i = 0; i < _SYSCALL_FILTER_SET_MAX; i++) {
|
||||
pid_t pid;
|
||||
|
||||
#if HAVE_VALGRIND_VALGRIND_H
|
||||
if (RUNNING_ON_VALGRIND && IN_SET(i, SYSCALL_FILTER_SET_DEFAULT, SYSCALL_FILTER_SET_BASIC_IO, SYSCALL_FILTER_SET_SIGNAL)) {
|
||||
/* valgrind at least requires rt_sigprocmask(), read(), write(). */
|
||||
log_info("Running on valgrind, skipping %s", syscall_filter_sets[i].name);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#if HAS_FEATURE_ADDRESS_SANITIZER
|
||||
if (IN_SET(i, SYSCALL_FILTER_SET_DEFAULT, SYSCALL_FILTER_SET_BASIC_IO, SYSCALL_FILTER_SET_SIGNAL)) {
|
||||
/* ASAN at least requires sigaltstack(), read(), write(). */
|
||||
log_info("Running on address sanitizer, skipping %s", syscall_filter_sets[i].name);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
log_info("Testing %s", syscall_filter_sets[i].name);
|
||||
|
||||
pid = fork();
|
||||
|
@ -323,6 +341,13 @@ static void test_protect_sysctl(void) {
|
|||
|
||||
assert_se(seccomp_protect_sysctl() >= 0);
|
||||
|
||||
#if HAVE_VALGRIND_VALGRIND_H
|
||||
if (RUNNING_ON_VALGRIND) {
|
||||
log_info("Running on valgrind, skipping syscall/EPERM test");
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined __NR__sysctl && __NR__sysctl >= 0
|
||||
assert_se(syscall(__NR__sysctl, 0, 0, 0) < 0);
|
||||
assert_se(errno == EPERM);
|
||||
|
@ -525,6 +550,16 @@ static void test_memory_deny_write_execute_mmap(void) {
|
|||
log_notice("Not root, skipping %s", __func__);
|
||||
return;
|
||||
}
|
||||
#if HAVE_VALGRIND_VALGRIND_H
|
||||
if (RUNNING_ON_VALGRIND) {
|
||||
log_notice("Running on valgrind, skipping %s", __func__);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if HAS_FEATURE_ADDRESS_SANITIZER
|
||||
log_notice("Running on address sanitizer, skipping %s", __func__);
|
||||
return;
|
||||
#endif
|
||||
|
||||
pid = fork();
|
||||
assert_se(pid >= 0);
|
||||
|
@ -585,6 +620,16 @@ static void test_memory_deny_write_execute_shmat(void) {
|
|||
log_notice("Not root, skipping %s", __func__);
|
||||
return;
|
||||
}
|
||||
#if HAVE_VALGRIND_VALGRIND_H
|
||||
if (RUNNING_ON_VALGRIND) {
|
||||
log_notice("Running on valgrind, skipping %s", __func__);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if HAS_FEATURE_ADDRESS_SANITIZER
|
||||
log_notice("Running on address sanitizer, skipping %s", __func__);
|
||||
return;
|
||||
#endif
|
||||
|
||||
shmid = shmget(IPC_PRIVATE, page_size(), 0);
|
||||
assert_se(shmid >= 0);
|
||||
|
|
Loading…
Reference in a new issue