Skip to contentSkip to conversation

seccomp: Stub for !HAVE_ARCH_SECCOMP_FILTER

PATCH Applied Linus Walleij 2 participants 2 messages Oct 22, 2024 Secure computing

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 seccomp: Stub for !HAVE_ARCH_SECCOMP_FILTER

If we have CONFIG_SECCOMP but not CONFIG_HAVE_ARCH_SECCOMP_FILTER we get a compilation error:

../kernel/entry/common.c: In function 'syscall_trace_enter':
../kernel/entry/common.c:55:23: error: implicit declaration of function '__secure_computing' [-Werror=implicit-function-declaration]

   55 |                 ret = __secure_computing(NULL);
      |                       ^~~~~~~~~~~~~~~~~~

This is because generic entry calls __secure_computing() unconditionally.

Provide the needed stub similar to how current ARM does this by calling secure_computing_strict() in the absence of secure_computing(). This is similar to what is done for ARM in arch/arm/kernel/ptrace.c.

---
Changes in v2:
- Call secure_computing_strict() instead of providing
a dumb stub for __secure_computing().
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 include/linux/seccomp.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/seccomp.h +5 -0
index 709ad84809e1..341980599c71 100644
@@ -32,6 +32,11 @@ static inline int secure_computing(void)
 }
 #else
 extern void secure_computing_strict(int this_syscall);
+static inline int __secure_computing(const struct seccomp_data *sd)
+{
+	secure_computing_strict(sd->nr);
+	return 0;
+}
 #endif
 
 extern long prctl_get_seccomp(void);

---
base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc
change-id: 20241008-seccomp-compile-error-83f367447d56

Best regards,

Signature · 1 line
Linus Walleij <[email protected]>
maintainer Applied
#1 lore raw
Quoted 9 lines · Linus Walleij

If we have CONFIG_SECCOMP but not CONFIG_HAVE_ARCH_SECCOMP_FILTER we get a compilation error:

../kernel/entry/common.c: In function 'syscall_trace_enter':
../kernel/entry/common.c:55:23: error: implicit declaration of function '__secure_computing' [-Werror=implicit-function-declaration]

   55 |                 ret = __secure_computing(NULL);
      |                       ^~~~~~~~~~~~~~~~~~

[...]

Applied to for-next/seccomp, thanks!

[1/1] seccomp: Stub for !HAVE_ARCH_SECCOMP_FILTER
https://git.kernel.org/kees/c/8cf8dfceebda

Take care,

Signature · 1 line
Kees Cook