[File] [PATCH 2/2] seccomp: fix the build with kernel headers older than 5.9

Yegor Yefremov yegorslists at googlemail.com
Tue Nov 3 00:00:39 EST 2026


openat2, faccessat2 and close_range were added in Linux 5.6, 5.8 and
5.9. With older kernel headers, libseccomp maps them to undefined
__NR_* macros:

  seccomp.c:59:52: error: '__NR_openat2' undeclared (first use in this function)

Only add the ENOSYS rules when the syscall numbers are defined, like
it is already done for other syscalls.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yegor Yefremov <yegorslists at googlemail.com>
---
 src/seccomp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/seccomp.c b/src/seccomp.c
index ea27a3a8..376e09b0 100644
--- a/src/seccomp.c
+++ b/src/seccomp.c
@@ -214,9 +214,15 @@ enable_sandbox(int flags, int action)
 	ALLOW_RULE(writev);
 
 	/* Newer variants we don't use. ENOSYS lets glibc fall back. */
+#ifdef __NR_openat2
 	ERRNO_RULE(openat2);
+#endif
+#ifdef __NR_faccessat2
 	ERRNO_RULE(faccessat2);
+#endif
+#ifdef __NR_close_range
 	ERRNO_RULE(close_range);
+#endif
 
 
 #if 0
-- 
2.34.1



More information about the File mailing list