Skip to contentSkip to conversation

switch to using asm-generic for seccomp.h

PATCH In review Kees Cook 2 participants 11 messages Mar 5, 2015 – Mar 11, 2015

Subsystems (8)
Arm (32-bit) x86 PowerPC MIPS +4 more subsystems
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

v3 cover switch to using asm-generic for seccomp.h

Most architectures don't need to do much special for the strict-mode seccomp syscall entries. Remove the redundant headers and reduce the others.

---
v3:
- split patch series by architecture
- fix up architectures that need sigreturn overrides (ingo) v2:
- use Kbuild "generic-y" instead of explicit #include lines (sfr)

author
#1 lore raw

PATCH v3 1/8 seccomp: allow COMPAT sigreturn overrides

Some architectures may need to override the compat sigreturn definition, as is already possible in the non-compat case.

---
 include/asm-generic/seccomp.h | 2 ++
 1 file changed, 2 insertions(+)
include/asm-generic/seccomp.h +2 -0
index 9fa1f653ed3b..c9ccafa0d99a 100644
@@ -17,7 +17,9 @@
 #define __NR_seccomp_read_32		__NR_read
 #define __NR_seccomp_write_32		__NR_write
 #define __NR_seccomp_exit_32		__NR_exit
+#ifndef __NR_seccomp_sigreturn_32
 #define __NR_seccomp_sigreturn_32	__NR_rt_sigreturn
+#endif
 #endif /* CONFIG_COMPAT && ! already defined */
 
 #define __NR_seccomp_read		__NR_read
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH v3 2/8 arm: use asm-generic for seccomp.h

In reply to Kees Cook

Switch to using the newly created asm-generic/seccomp.h for the seccomp strict mode syscall definitions. Definitions were identical.

---
 arch/arm/include/asm/Kbuild    |  1 +
 arch/arm/include/asm/seccomp.h | 11 -----------
 2 files changed, 1 insertion(+), 11 deletions(-)
 delete mode 100644 arch/arm/include/asm/seccomp.h
arch/arm/include/asm/Kbuild +1 -0
index fe74c0d1e485..d7be5a9fd171 100644
@@ -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
deleted file mode 100644
index 52b156b341f5..000000000000
@@ -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 */
Signature · 1 line
1.9.1
author
#3 lore raw

PATCH v3 3/8 microblaze: use asm-generic for seccomp.h

In reply to Kees Cook

Switch to using the newly created asm-generic/seccomp.h for the seccomp strict mode syscall definitions. Since microblaze is 32-bit, the COMPAT seccomp defines are unused and can be dropped. The obsolete sigreturn for seccomp strict mode is retained as an override. Remaining definitions are identical.

---
 arch/microblaze/include/asm/seccomp.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
arch/microblaze/include/asm/seccomp.h +1 -7
index 0d912758a0d7..204618a2ce84 100644
@@ -3,14 +3,8 @@
 
 #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
+#include <asm-generic/seccomp.h>
 
 #endif	/* _ASM_MICROBLAZE_SECCOMP_H */
Signature · 1 line
1.9.1
author
#4 lore raw

PATCH v3 4/8 mips: switch to using asm-generic for seccomp.h

In reply to Kees Cook

Switch to using the newly created asm-generic/seccomp.h for the seccomp strict mode syscall definitions. COMPAT definitions retain their overrides and the remaining definitions were identical.

---
 arch/mips/include/asm/seccomp.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
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 */
Signature · 1 line
1.9.1
author
#5 lore raw

PATCH v3 5/8 parisc: switch to using asm-generic for seccomp.h

In reply to Kees Cook

Switch to using the newly created asm-generic/seccomp.h for the seccomp strict mode syscall definitions. Definitions were identical.

---
 arch/parisc/include/asm/Kbuild    |  1 +
 arch/parisc/include/asm/seccomp.h | 16 ----------------
 2 files changed, 1 insertion(+), 16 deletions(-)
 delete mode 100644 arch/parisc/include/asm/seccomp.h
arch/parisc/include/asm/Kbuild +1 -0
index 8686237a3c3c..12b341d04f88 100644
@@ -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
deleted file mode 100644
index 015f7887aa29..000000000000
@@ -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 */
Signature · 1 line
1.9.1
author
#6 lore raw

PATCH v3 6/8 powerpc: switch to using asm-generic for seccomp.h

In reply to Kees Cook

Switch to using the newly created asm-generic/seccomp.h for the seccomp strict mode syscall definitions. The obsolete sigreturn in COMPAT mode is retained as an override. Remaining definitions are identical, though they incorrectly appeared in uapi, which has been corrected.

---
 arch/powerpc/include/asm/seccomp.h      | 10 ++++++++++
 arch/powerpc/include/uapi/asm/Kbuild    |  1 -
 arch/powerpc/include/uapi/asm/seccomp.h | 16 ----------------
 3 files changed, 10 insertions(+), 17 deletions(-)
 create mode 100644 arch/powerpc/include/asm/seccomp.h
 delete mode 100644 arch/powerpc/include/uapi/asm/seccomp.h
arch/powerpc/include/asm/seccomp.h new file +10 -0
new file mode 100644
index 000000000000..c1818e35cf02
@@ -0,0 +1,10 @@
+#ifndef _ASM_POWERPC_SECCOMP_H
+#define _ASM_POWERPC_SECCOMP_H
+
+#include <linux/unistd.h>
+
+#define __NR_seccomp_sigreturn_32 __NR_sigreturn
+
+#include <asm-generic/seccomp.h>
+
+#endif	/* _ASM_POWERPC_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 -14
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
author
#7 lore raw

PATCH v3 7/8 sparc: switch to using asm-generic for seccomp.h

In reply to Kees Cook

Switch to using the newly created asm-generic/seccomp.h for the seccomp strict mode syscall definitions. The obsolete sigreturn in COMPAT mode is retained as an override. Remaining definitions are identical. Also corrected missing #define for header reinclusion protection.

---
 arch/sparc/include/asm/seccomp.h | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
arch/sparc/include/asm/seccomp.h +3 -8
index adca1bce41d4..5ef8826d44f8 100644
@@ -1,15 +1,10 @@
 #ifndef _ASM_SECCOMP_H
+#define _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
 
+#include <asm-generic/seccomp.h>
+
 #endif /* _ASM_SECCOMP_H */
Signature · 1 line
1.9.1
author
#8 lore raw

PATCH v3 8/8 x86: switch to using asm-generic for seccomp.h

In reply to Kees Cook

Switch to using the newly created asm-generic/seccomp.h for the seccomp strict mode syscall definitions. The obsolete sigreturn syscall override is retained in 32-bit mode, and the ia32 syscall overrides are used in the compat case. Remaining definitions were identical.

---
 arch/x86/include/asm/seccomp.h    | 21 ++++++++++++++++++---
 arch/x86/include/asm/seccomp_32.h | 11 -----------
 arch/x86/include/asm/seccomp_64.h | 17 -----------------
 3 files changed, 18 insertions(+), 31 deletions(-)
 delete mode 100644 arch/x86/include/asm/seccomp_32.h
 delete mode 100644 arch/x86/include/asm/seccomp_64.h
arch/x86/include/asm/seccomp.h +18 -3
index 0f3d7f099224..0c8c7c8861b4 100644
@@ -1,5 +1,20 @@
+#ifndef _ASM_X86_SECCOMP_H
+#define _ASM_X86_SECCOMP_H
+
+#include <asm/unistd.h>
+
 #ifdef CONFIG_X86_32
-# include <asm/seccomp_32.h>
-#else
-# include <asm/seccomp_64.h>
+#define __NR_seccomp_sigreturn		__NR_sigreturn
 #endif
+
+#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
+
+#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 · 1 line
1.9.1
Acked-by on v3 8/8
#9 lore raw

Re: [PATCH v3 8/8] x86: switch to using asm-generic for seccomp.h

Quoted 7 lines · Kees Cook

Switch to using the newly created asm-generic/seccomp.h for the seccomp strict mode syscall definitions. The obsolete sigreturn syscall override is retained in 32-bit mode, and the ia32 syscall overrides are used in the compat case. Remaining definitions were identical.

Thanks,

Ingo

author
#10 lore raw
In reply to Kees Cook
Quoted 5 lines · Kees Cook

Most architectures don't need to do much special for the strict-mode seccomp syscall entries. Remove the redundant headers and reduce the others.

Hi Andrew,

Just a quick ping: are you able to pick up this series, or should I try to get this in on a per-arch basis?

Thanks!

-Kees

Quoted 7 lines

---
v3:
- split patch series by architecture
- fix up architectures that need sigreturn overrides (ingo) v2:
- use Kbuild "generic-y" instead of explicit #include lines (sfr)

Signature · 2 lines
Kees Cook
Chrome OS Security