[PATCH] seccomp: Stub for !HAVE_ARCH_SECCOMP_FILTER

Linus Walleij posted 1 patch 1 month, 2 weeks ago
There is a newer version of this series
include/linux/seccomp.h | 1 +
1 file changed, 1 insertion(+)
[PATCH] seccomp: Stub for !HAVE_ARCH_SECCOMP_FILTER
Posted by Linus Walleij 1 month, 2 weeks ago
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.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 include/linux/seccomp.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h
index 709ad84809e1..832c612c5b54 100644
--- a/include/linux/seccomp.h
+++ b/include/linux/seccomp.h
@@ -31,6 +31,7 @@ static inline int secure_computing(void)
 	return 0;
 }
 #else
+static inline int __secure_computing(const struct seccomp_data *sd) { return 0; }
 extern void secure_computing_strict(int this_syscall);
 #endif
 

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

Best regards,
-- 
Linus Walleij <linus.walleij@linaro.org>
Re: [PATCH] seccomp: Stub for !HAVE_ARCH_SECCOMP_FILTER
Posted by Kees Cook 1 month, 1 week ago
On Tue, Oct 08, 2024 at 10:29:43AM +0200, Linus Walleij wrote:
> If we have CONFIG_SECCOMP but not CONFIG_HAVE_ARCH_SECCOMP_FILTER
> we get a compilation error:
> [...]
> +static inline int __secure_computing(const struct seccomp_data *sd) { return 0; }

I don't think this is the right solution (for gaining ARM generic
syscall support). For example see how this is done currently on ARM:

#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
        if (secure_computing() == -1)
                return -1;
#else
        /* XXX: remove this once OABI gets fixed */
        secure_computing_strict(syscall_get_nr(current, regs));
#endif

If we just return 0, all of seccomp will get ignored. I think the
generic code needs to do something like the above...

-- 
Kees Cook