f8452f
From 65a066aae68744e889c114cee56dff5b48d872df Mon Sep 17 00:00:00 2001
f8452f
From: Jan Synacek <jsynacek@redhat.com>
f8452f
Date: Thu, 4 Jun 2020 16:55:52 +0200
f8452f
Subject: [PATCH] seccomp: fix __NR__sysctl usage
f8452f
f8452f
Loosely based on
f8452f
https://github.com/systemd/systemd/pull/14032 and
f8452f
https://github.com/systemd/systemd/pull/14268.
f8452f
f8452f
Related: #1843871
f8452f
---
f8452f
 src/test/test-seccomp.c | 4 ++--
f8452f
 1 file changed, 2 insertions(+), 2 deletions(-)
f8452f
f8452f
diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c
f8452f
index 4021a06e0e..009a2e1922 100644
f8452f
--- a/src/test/test-seccomp.c
f8452f
+++ b/src/test/test-seccomp.c
f8452f
@@ -237,14 +237,14 @@ static void test_protect_sysctl(void) {
f8452f
         assert_se(pid >= 0);
f8452f
 
f8452f
         if (pid == 0) {
f8452f
-#if __NR__sysctl > 0
f8452f
+#if defined __NR__sysctl &&  __NR__sysctl >= 0
f8452f
                 assert_se(syscall(__NR__sysctl, NULL) < 0);
f8452f
                 assert_se(errno == EFAULT);
f8452f
 #endif
f8452f
 
f8452f
                 assert_se(seccomp_protect_sysctl() >= 0);
f8452f
 
f8452f
-#if __NR__sysctl > 0
f8452f
+#if defined __NR__sysctl && __NR__sysctl >= 0
f8452f
                 assert_se(syscall(__NR__sysctl, 0, 0, 0) < 0);
f8452f
                 assert_se(errno == EPERM);
f8452f
 #endif