daandemeyer / rpms / systemd

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