Skip to contentSkip to conversation

seccomp: switch to using asm-generic for seccomp.h

PATCH Superseded Kees Cook 2 participants 3 messages Feb 28, 2015

Subsystems (9)
Arm (32-bit) x86 PowerPC MIPS +5 more subsystems

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 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.

---
 arch/arm/include/asm/seccomp.h          | 12 +-----------
 arch/microblaze/include/asm/seccomp.h   | 17 +----------------
 arch/mips/include/asm/seccomp.h         |  7 ++-----
 arch/parisc/include/asm/seccomp.h       | 17 +----------------
 arch/powerpc/include/asm/seccomp.h      |  1 +
 arch/powerpc/include/uapi/asm/Kbuild    |  1 -
 arch/powerpc/include/uapi/asm/seccomp.h | 16 ----------------
 arch/s390/include/asm/seccomp.h         | 17 +----------------
 arch/sh/include/asm/seccomp.h           | 11 +----------
 arch/sparc/include/asm/seccomp.h        | 16 +---------------
 arch/x86/include/asm/seccomp.h          | 21 ++++++++++++++++++---
 arch/x86/include/asm/seccomp_32.h       | 11 -----------
 arch/x86/include/asm/seccomp_64.h       | 17 -----------------
 13 files changed, 27 insertions(+), 137 deletions(-)
 create mode 100644 arch/powerpc/include/asm/seccomp.h
 delete mode 100644 arch/powerpc/include/uapi/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/seccomp.h +1 -11
index 52b156b341f5..66ca6a30bf5c 100644
@@ -1,11 +1 @@
-#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 */
+#include <asm-generic/seccomp.h>
arch/microblaze/include/asm/seccomp.h +1 -16
index 0d912758a0d7..66ca6a30bf5c 100644
@@ -1,16 +1 @@
-#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 */
+#include <asm-generic/seccomp.h>
arch/mips/include/asm/seccomp.h +2 -5
index f29c75cf83c6..1d8a2e2c75c1 100644
@@ -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/seccomp.h +1 -16
index 015f7887aa29..66ca6a30bf5c 100644
@@ -1,16 +1 @@
-#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 */
+#include <asm-generic/seccomp.h>
arch/powerpc/include/asm/seccomp.h new file +1 -0
new file mode 100644
index 000000000000..66ca6a30bf5c
@@ -0,0 +1 @@
+#include <asm-generic/seccomp.h>
arch/powerpc/include/uapi/asm/Kbuild +0 -1
index 7a3f795ac218..79c4068be278 100644
@@ -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
deleted file mode 100644
index 00c1d9133cfe..000000000000
@@ -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/seccomp.h +1 -16
index 781a9cf9b002..66ca6a30bf5c 100644
@@ -1,16 +1 @@
-#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 */
+#include <asm-generic/seccomp.h>
arch/sh/include/asm/seccomp.h +1 -10
index 3280ed3802ef..66ca6a30bf5c 100644
@@ -1,10 +1 @@
-#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 */
+#include <asm-generic/seccomp.h>
arch/sparc/include/asm/seccomp.h +1 -15
index adca1bce41d4..66ca6a30bf5c 100644
@@ -1,15 +1 @@
-#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 */
+#include <asm-generic/seccomp.h>
arch/x86/include/asm/seccomp.h +18 -3
index 0f3d7f099224..b13ac5f63702 100644
@@ -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
deleted file mode 100644
index b811d6f5780c..000000000000
@@ -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
deleted file mode 100644
index 84ec1bd161a5..000000000000
@@ -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
#1 lore raw

Hi Kees,

Quoted 8 lines · On Fri, 27 Feb 2015 16:52:29 -0800 Kees Cook <[email protected]> wrote:
arch/arm/include/asm/seccomp.h +0 -2
index 52b156b341f5..66ca6a30bf5c 100644
@@ -1,11 +1 @@
-#ifndef _ASM_ARM_SECCOMP_H
-#define _ASM_ARM_SECCOMP_H

arch/arm/include/asm/seccomp.h line 1

Quoted 10 lines
arch/arm/include/asm/seccomp.h +1 -9
-
-#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 */
+#include <asm-generic/seccomp.h>

I think that these cases (where you replace the file by a stub that just include <asm-generic/seccomp.h>) can be replaced by removing the file completely and adding

generic-y = seccomp.h

to <ARCH>/include/asm/Kbuild

Signature · 9 lines
Cheers,
Stephen Rothwell                    sfr at canb.auug.org.au
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150228/9e5ceab2/attachment.sig>
author
#2 lore raw
Quoted 26 lines · Stephen Rothwell

Hi Kees,

Quoted 8 lines · On Fri, 27 Feb 2015 16:52:29 -0800 Kees Cook <[email protected]> wrote:
arch/arm/include/asm/seccomp.h +0 -2
index 52b156b341f5..66ca6a30bf5c 100644
@@ -1,11 +1 @@
-#ifndef _ASM_ARM_SECCOMP_H
-#define _ASM_ARM_SECCOMP_H

arch/arm/include/asm/seccomp.h line 1

Quoted 10 lines
arch/arm/include/asm/seccomp.h +1 -9
-
-#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 */
+#include <asm-generic/seccomp.h>

I think that these cases (where you replace the file by a stub that just include <asm-generic/seccomp.h>) can be replaced by removing the file completely and adding

Quoted 3 lines

generic-y = seccomp.h

to <ARCH>/include/asm/Kbuild

Ah-ha! I thought total removal was possible, but I lacked the Kbuild piece. There are a lot of arch/ headers that are just the one line. Maybe I should send a another patch to clean up those?

-Kees

Signature · 2 lines
Kees Cook
Chrome OS Security