anitazha / rpms / systemd

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