seccomp: switch to using asm-generic for seccomp.h
Subsystems (9)
PATCH v2 1/1 seccomp: switch to using asm-generic for seccomp.h
Most architectures don't need to do anything special for the strict seccomp syscall entries. Remove the redundant headers and reduce the others.
---
v2:
- use Kbuild "generic-y" instead of explicit #include lines (sfr)
--- arch/arm/include/asm/Kbuild | 1 + arch/arm/include/asm/seccomp.h | 11 ----------- arch/microblaze/include/asm/Kbuild | 1 + arch/microblaze/include/asm/seccomp.h | 16 ---------------- arch/mips/include/asm/seccomp.h | 7 ++----- arch/parisc/include/asm/Kbuild | 1 + arch/parisc/include/asm/seccomp.h | 16 ---------------- arch/powerpc/include/asm/Kbuild | 1 + arch/powerpc/include/uapi/asm/Kbuild | 1 - arch/powerpc/include/uapi/asm/seccomp.h | 16 ---------------- arch/s390/include/asm/Kbuild | 1 + arch/s390/include/asm/seccomp.h | 16 ---------------- arch/sh/include/asm/Kbuild | 1 + arch/sh/include/asm/seccomp.h | 10 ---------- arch/sparc/include/asm/Kbuild | 1 + arch/sparc/include/asm/seccomp.h | 15 --------------- arch/x86/include/asm/seccomp.h | 21 ++++++++++++++++++--- arch/x86/include/asm/seccomp_32.h | 11 ----------- arch/x86/include/asm/seccomp_64.h | 17 ----------------- 19 files changed, 27 insertions(+), 137 deletions(-) delete mode 100644 arch/arm/include/asm/seccomp.h delete mode 100644 arch/microblaze/include/asm/seccomp.h delete mode 100644 arch/parisc/include/asm/seccomp.h delete mode 100644 arch/powerpc/include/uapi/asm/seccomp.h delete mode 100644 arch/s390/include/asm/seccomp.h delete mode 100644 arch/sh/include/asm/seccomp.h delete mode 100644 arch/sparc/include/asm/seccomp.h delete mode 100644 arch/x86/include/asm/seccomp_32.h delete mode 100644 arch/x86/include/asm/seccomp_64.h
arch/arm/include/asm/Kbuild +1 -0
@@ -22,6 +22,7 @@ generic-y += preempt.h generic-y += resource.h generic-y += rwsem.h generic-y += scatterlist.h +generic-y += seccomp.h generic-y += sections.h generic-y += segment.h generic-y += sembuf.h
arch/arm/include/asm/seccomp.h deleted +0 -11
@@ -1,11 +0,0 @@ -#ifndef _ASM_ARM_SECCOMP_H -#define _ASM_ARM_SECCOMP_H - -#include <linux/unistd.h> - -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_rt_sigreturn - -#endif /* _ASM_ARM_SECCOMP_H */
arch/microblaze/include/asm/Kbuild +1 -0
@@ -8,5 +8,6 @@ generic-y += irq_work.h generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += scatterlist.h +generic-y += seccomp.h generic-y += syscalls.h generic-y += trace_clock.h
arch/microblaze/include/asm/seccomp.h deleted +0 -16
@@ -1,16 +0,0 @@ -#ifndef _ASM_MICROBLAZE_SECCOMP_H -#define _ASM_MICROBLAZE_SECCOMP_H - -#include <linux/unistd.h> - -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_sigreturn - -#define __NR_seccomp_read_32 __NR_read -#define __NR_seccomp_write_32 __NR_write -#define __NR_seccomp_exit_32 __NR_exit -#define __NR_seccomp_sigreturn_32 __NR_sigreturn - -#endif /* _ASM_MICROBLAZE_SECCOMP_H */
arch/mips/include/asm/seccomp.h +2 -5
@@ -2,11 +2,6 @@#include <linux/unistd.h> -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_rt_sigreturn -/* * Kludge alert: *
@@ -29,4 +24,6 @@#endif /* CONFIG_MIPS32_O32 */ +#include <asm-generic/seccomp.h> +#endif /* __ASM_SECCOMP_H */
arch/parisc/include/asm/Kbuild +1 -0
@@ -20,6 +20,7 @@ generic-y += param.h generic-y += percpu.h generic-y += poll.h generic-y += preempt.h +generic-y += seccomp.h generic-y += segment.h generic-y += topology.h generic-y += trace_clock.h
arch/parisc/include/asm/seccomp.h deleted +0 -16
@@ -1,16 +0,0 @@ -#ifndef _ASM_PARISC_SECCOMP_H -#define _ASM_PARISC_SECCOMP_H - -#include <linux/unistd.h> - -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_rt_sigreturn - -#define __NR_seccomp_read_32 __NR_read -#define __NR_seccomp_write_32 __NR_write -#define __NR_seccomp_exit_32 __NR_exit -#define __NR_seccomp_sigreturn_32 __NR_rt_sigreturn - -#endif /* _ASM_PARISC_SECCOMP_H */
arch/powerpc/include/asm/Kbuild +1 -0
@@ -5,5 +5,6 @@ generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += rwsem.h generic-y += scatterlist.h +generic-y += seccomp.h generic-y += trace_clock.h generic-y += vtime.h
arch/powerpc/include/uapi/asm/Kbuild +0 -1
@@ -25,7 +25,6 @@ header-y += posix_types.h header-y += ps3fb.h header-y += ptrace.h header-y += resource.h -header-y += seccomp.h header-y += sembuf.h header-y += setup.h header-y += shmbuf.h
arch/powerpc/include/uapi/asm/seccomp.h deleted +0 -16
@@ -1,16 +0,0 @@ -#ifndef _ASM_POWERPC_SECCOMP_H -#define _ASM_POWERPC_SECCOMP_H - -#include <linux/unistd.h> - -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_rt_sigreturn - -#define __NR_seccomp_read_32 __NR_read -#define __NR_seccomp_write_32 __NR_write -#define __NR_seccomp_exit_32 __NR_exit -#define __NR_seccomp_sigreturn_32 __NR_sigreturn - -#endif /* _ASM_POWERPC_SECCOMP_H */
arch/s390/include/asm/Kbuild +1 -0
@@ -5,4 +5,5 @@ generic-y += irq_work.h generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += scatterlist.h +generic-y += seccomp.h generic-y += trace_clock.h
arch/s390/include/asm/seccomp.h deleted +0 -16
@@ -1,16 +0,0 @@ -#ifndef _ASM_S390_SECCOMP_H -#define _ASM_S390_SECCOMP_H - -#include <linux/unistd.h> - -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_sigreturn - -#define __NR_seccomp_read_32 __NR_read -#define __NR_seccomp_write_32 __NR_write -#define __NR_seccomp_exit_32 __NR_exit -#define __NR_seccomp_sigreturn_32 __NR_sigreturn - -#endif /* _ASM_S390_SECCOMP_H */
arch/sh/include/asm/Kbuild +1 -0
@@ -25,6 +25,7 @@ generic-y += poll.h generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h +generic-y += seccomp.h generic-y += sembuf.h generic-y += serial.h generic-y += shmbuf.h
arch/sh/include/asm/seccomp.h deleted +0 -10
@@ -1,10 +0,0 @@ -#ifndef __ASM_SECCOMP_H - -#include <linux/unistd.h> - -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_rt_sigreturn - -#endif /* __ASM_SECCOMP_H */
arch/sparc/include/asm/Kbuild +1 -0
@@ -16,6 +16,7 @@ generic-y += module.h generic-y += mutex.h generic-y += preempt.h generic-y += scatterlist.h +generic-y += seccomp.h generic-y += serial.h generic-y += trace_clock.h generic-y += types.h
arch/sparc/include/asm/seccomp.h deleted +0 -15
@@ -1,15 +0,0 @@ -#ifndef _ASM_SECCOMP_H - -#include <linux/unistd.h> - -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_rt_sigreturn - -#define __NR_seccomp_read_32 __NR_read -#define __NR_seccomp_write_32 __NR_write -#define __NR_seccomp_exit_32 __NR_exit -#define __NR_seccomp_sigreturn_32 __NR_sigreturn - -#endif /* _ASM_SECCOMP_H */
arch/x86/include/asm/seccomp.h +18 -3
@@ -1,5 +1,20 @@ +#ifndef _ASM_X86_SECCOMP_H +#define _ASM_X86_SECCOMP_H + +#include <asm/unistd.h> + +#ifdef CONFIG_COMPAT +#include <asm/ia32_unistd.h> +#define __NR_seccomp_read_32 __NR_ia32_read +#define __NR_seccomp_write_32 __NR_ia32_write +#define __NR_seccomp_exit_32 __NR_ia32_exit +#define __NR_seccomp_sigreturn_32 __NR_ia32_sigreturn +#endif +#ifdef CONFIG_X86_32 -# include <asm/seccomp_32.h> -#else -# include <asm/seccomp_64.h> +#define __NR_seccomp_sigreturn __NR_sigreturn#endif + +#include <asm-generic/seccomp.h> + +#endif /* _ASM_X86_SECCOMP_H */
arch/x86/include/asm/seccomp_32.h deleted +0 -11
@@ -1,11 +0,0 @@ -#ifndef _ASM_X86_SECCOMP_32_H -#define _ASM_X86_SECCOMP_32_H - -#include <linux/unistd.h> - -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_sigreturn - -#endif /* _ASM_X86_SECCOMP_32_H */
arch/x86/include/asm/seccomp_64.h deleted +0 -17
@@ -1,17 +0,0 @@ -#ifndef _ASM_X86_SECCOMP_64_H -#define _ASM_X86_SECCOMP_64_H - -#include <linux/unistd.h> -#include <asm/ia32_unistd.h> - -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_rt_sigreturn - -#define __NR_seccomp_read_32 __NR_ia32_read -#define __NR_seccomp_write_32 __NR_ia32_write -#define __NR_seccomp_exit_32 __NR_ia32_exit -#define __NR_seccomp_sigreturn_32 __NR_ia32_sigreturn - -#endif /* _ASM_X86_SECCOMP_64_H */
Signature · 6 lines
1.9.1 -- Kees Cook Chrome OS Security
Quoted 5 lines · Kees Cook
Most architectures don't need to do anything special for the strict seccomp syscall entries. Remove the redundant headers and reduce the others.
19 files changed, 27 insertions(+), 137 deletions(-)
Lovely cleanup factor.
Just to make sure, are you sure the 32-bit details are identical across architectures?
For example some architectures did this:
Quoted 7 lines
arch/microblaze/include/asm/seccomp.h deleted +0
-4@@ -1,16 +0,0 @@ -#ifndef _ASM_MICROBLAZE_SECCOMP_H -#define _ASM_MICROBLAZE_SECCOMP_H - -#include <linux/unistd.h>
arch/microblaze/include/asm/seccomp.h line 14
Quoted 10 lines
arch/microblaze/include/asm/seccomp.h deleted +0
-10- -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_sigreturn - -#define __NR_seccomp_read_32 __NR_read -#define __NR_seccomp_write_32 __NR_write -#define __NR_seccomp_exit_32 __NR_exit -#define __NR_seccomp_sigreturn_32 __NR_sigreturn
others did this:
Quoted 13 lines
arch/x86/include/asm/seccomp_64.h deleted +0
-7@@ -1,17 +0,0 @@ -#ifndef _ASM_X86_SECCOMP_64_H -#define _ASM_X86_SECCOMP_64_H - -#include <linux/unistd.h> -#include <asm/ia32_unistd.h> - -#define __NR_seccomp_read __NR_read
arch/x86/include/asm/seccomp_64.h line 17
Quoted 10 lines
arch/x86/include/asm/seccomp_64.h deleted +0
-10-#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_rt_sigreturn - -#define __NR_seccomp_read_32 __NR_ia32_read -#define __NR_seccomp_write_32 __NR_ia32_write -#define __NR_seccomp_exit_32 __NR_ia32_exit -#define __NR_seccomp_sigreturn_32 __NR_ia32_sigreturn - -#endif /* _ASM_X86_SECCOMP_64_H */
While in yet another case you kept the syscall mappings:
Quoted 16 lines
arch/x86/include/asm/seccomp.h +13
-0@@ -1,5 +1,20 @@ +#ifndef _ASM_X86_SECCOMP_H +#define _ASM_X86_SECCOMP_H + +#include <asm/unistd.h> + +#ifdef CONFIG_COMPAT +#include <asm/ia32_unistd.h> +#define __NR_seccomp_read_32 __NR_ia32_read +#define __NR_seccomp_write_32 __NR_ia32_write +#define __NR_seccomp_exit_32 __NR_ia32_exit +#define __NR_seccomp_sigreturn_32 __NR_ia32_sigreturn +#endif +
arch/x86/include/asm/seccomp.h line 20
Quoted 10 lines
arch/x86/include/asm/seccomp.h +5
-3#ifdef CONFIG_X86_32 -# include <asm/seccomp_32.h> -#else -# include <asm/seccomp_64.h> +#define __NR_seccomp_sigreturn __NR_sigreturn#endif + +#include <asm-generic/seccomp.h> + +#endif /* _ASM_X86_SECCOMP_H */
It might all be correct, but it's not obvious to me.
Thanks,
Ingo
Quoted 7 lines · Ingo Molnar
Quoted 3 lines · Kees Cook
Most architectures don't need to do anything special for the strict seccomp syscall entries. Remove the redundant headers and reduce the others.
Quoted 6 lines
Quoted 1 line
19 files changed, 27 insertions(+), 137 deletions(-)Lovely cleanup factor.
Just to make sure, are you sure the 32-bit details are identical across architectures?
I did "gcc -E -dM" style output comparisons on the architectures I had compilers for, and the buildbot hasn't complained on any of the others (though see the bottom of this email).
Quoted 12 lines
For example some architectures did this:
Quoted 9 lines
arch/microblaze/include/asm/seccomp.h deleted +0
-6@@ -1,16 +0,0 @@ -#ifndef _ASM_MICROBLAZE_SECCOMP_H -#define _ASM_MICROBLAZE_SECCOMP_H - -#include <linux/unistd.h> - -#define __NR_seccomp_read __NR_read
Quoted 8 lines
arch/microblaze/include/asm/seccomp.h line 14
Quoted 8 lines
arch/microblaze/include/asm/seccomp.h deleted +0
-8-#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit -#define __NR_seccomp_sigreturn __NR_sigreturn - -#define __NR_seccomp_read_32 __NR_read -#define __NR_seccomp_write_32 __NR_write -#define __NR_seccomp_exit_32 __NR_exit -#define __NR_seccomp_sigreturn_32 __NR_sigreturn
The asm-generic uses the same syscall numbers from both 64 and 32, which matches most architectures, and those are the ones that had their seccomp.h entirely eliminated.
Quoted 17 lines
others did this:
Quoted 15 lines
arch/x86/include/asm/seccomp_64.h deleted +0
-9@@ -1,17 +0,0 @@ -#ifndef _ASM_X86_SECCOMP_64_H -#define _ASM_X86_SECCOMP_64_H - -#include <linux/unistd.h> -#include <asm/ia32_unistd.h> - -#define __NR_seccomp_read __NR_read -#define __NR_seccomp_write __NR_write -#define __NR_seccomp_exit __NR_exit
Quoted 8 lines
arch/x86/include/asm/seccomp_64.h line 17
Quoted 8 lines
arch/x86/include/asm/seccomp_64.h deleted +0
-8-#define __NR_seccomp_sigreturn __NR_rt_sigreturn - -#define __NR_seccomp_read_32 __NR_ia32_read -#define __NR_seccomp_write_32 __NR_ia32_write -#define __NR_seccomp_exit_32 __NR_ia32_exit -#define __NR_seccomp_sigreturn_32 __NR_ia32_sigreturn - -#endif /* _ASM_X86_SECCOMP_64_H */
Well, this was x86's split config that was consolidated into the file below:
Quoted 23 lines
While in yet another case you kept the syscall mappings:
Quoted 20 lines
arch/x86/include/asm/seccomp.h +13
-3@@ -1,5 +1,20 @@ +#ifndef _ASM_X86_SECCOMP_H +#define _ASM_X86_SECCOMP_H + +#include <asm/unistd.h> + +#ifdef CONFIG_COMPAT +#include <asm/ia32_unistd.h> +#define __NR_seccomp_read_32 __NR_ia32_read +#define __NR_seccomp_write_32 __NR_ia32_write +#define __NR_seccomp_exit_32 __NR_ia32_exit +#define __NR_seccomp_sigreturn_32 __NR_ia32_sigreturn +#endif +#ifdef CONFIG_X86_32 -# include <asm/seccomp_32.h> -#else -# include <asm/seccomp_64.h>
Quoted 8 lines
arch/x86/include/asm/seccomp.h line 20
Quoted 6 lines
arch/x86/include/asm/seccomp.h +5
-0+#define __NR_seccomp_sigreturn __NR_sigreturn#endif + +#include <asm-generic/seccomp.h> + +#endif /* _ASM_X86_SECCOMP_H */ It might all be correct, but it's not obvious to me.
The x86 change was the most complex as it removed a seccomp_32. and seccomp_64.h file and merged into a single asm/seccomp.h to provide overrides for the _32 #defines.
However, in looking at it now... I see some flip/flopping of __NR_sigreturn and __NR_rt_sigreturn between some of the architectures. Let me study that and send a v3. I think there are some accidental changes on microblaze and powerpc.
-Kees
Signature · 2 lines
Kees Cook Chrome OS Security