In compat64, the syscalls have the same numbers as in native. Set the seccomp mode compat syscalls accordingly.
Signed-off-by: Tudor Cretu tudor.cretu@arm.com --- arch/arm64/include/asm/seccomp.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/include/asm/seccomp.h b/arch/arm64/include/asm/seccomp.h index 30256233788b..617250b9aa62 100644 --- a/arch/arm64/include/asm/seccomp.h +++ b/arch/arm64/include/asm/seccomp.h @@ -11,10 +11,23 @@ #include <asm/unistd.h>
#ifdef CONFIG_COMPAT -#define __NR_seccomp_read_32 __NR_compat_read -#define __NR_seccomp_write_32 __NR_compat_write -#define __NR_seccomp_exit_32 __NR_compat_exit -#define __NR_seccomp_sigreturn_32 __NR_compat_rt_sigreturn +static inline const int *get_compat_mode1_syscalls(void) +{ + static const int mode1_syscalls_compat[] = { +#ifdef CONFIG_COMPAT32 + __NR_compat_read, __NR_compat_write, + __NR_compat_exit, __NR_compat_rt_sigreturn, +#else + __NR_read, __NR_write, + __NR_exit, __NR_rt_sigreturn, +#endif + -1, /* negative terminated */ + }; + return mode1_syscalls_compat; +} + +#define get_compat_mode1_syscalls get_compat_mode1_syscalls + #endif /* CONFIG_COMPAT */
#include <asm-generic/seccomp.h>
On 02/08/2022 12:13, Tudor Cretu wrote:
In compat64, the syscalls have the same numbers as in native. Set the seccomp mode compat syscalls accordingly.
Signed-off-by: Tudor Cretu tudor.cretu@arm.com
arch/arm64/include/asm/seccomp.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/include/asm/seccomp.h b/arch/arm64/include/asm/seccomp.h index 30256233788b..617250b9aa62 100644 --- a/arch/arm64/include/asm/seccomp.h +++ b/arch/arm64/include/asm/seccomp.h @@ -11,10 +11,23 @@ #include <asm/unistd.h> #ifdef CONFIG_COMPAT
I might be missing something, but wouldn't it do the trick to simply change this line to #ifdef CONFIG_COMPAT32 instead? This way you're not defining any of __NR_seccomp_*_32 here in compat64, and then asm-generic/seccomp.h will fall back to the the native __NR_* on its own.
While we're here we should probably also take care of the other #ifdef CONFIG_COMPAT in this file, I suspect the macros defined there should have the same value as the native ones in compat64.
Kevin
-#define __NR_seccomp_read_32 __NR_compat_read -#define __NR_seccomp_write_32 __NR_compat_write -#define __NR_seccomp_exit_32 __NR_compat_exit -#define __NR_seccomp_sigreturn_32 __NR_compat_rt_sigreturn +static inline const int *get_compat_mode1_syscalls(void) +{
- static const int mode1_syscalls_compat[] = {
+#ifdef CONFIG_COMPAT32
__NR_compat_read, __NR_compat_write,
__NR_compat_exit, __NR_compat_rt_sigreturn,
+#else
__NR_read, __NR_write,
__NR_exit, __NR_rt_sigreturn,
+#endif
-1, /* negative terminated */
- };
- return mode1_syscalls_compat;
+}
+#define get_compat_mode1_syscalls get_compat_mode1_syscalls
- #endif /* CONFIG_COMPAT */
#include <asm-generic/seccomp.h>
linux-morello@op-lists.linaro.org