summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorNicolas Schichan <nschichan@freebox.fr>2013-05-10 09:58:01 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2013-05-10 12:59:01 +1000
commitca01d7dc4d427cc791f3f77f4a06c1623475d293 (patch)
tree01d52cb8615b3c3130c572c8ee424055850c469b /arch
parente4390676c9078024fef2bb54724c0d95b206f795 (diff)
seccomp: add generic code for jitted seccomp filters.
This patchset adds support for jitted seccomp BPF filters, with the required modifications to make it work on the ARM architecture. - The first patch in the serie adds the required boiler plate in the core kernel seccomp code to invoke the JIT compilation/free code. - The second patch reworks the ARM BPF JIT code to make the generation process less dependent on struct sk_filter. - The last patch actually implements the ARM part in the BPF jit code. Some benchmarks, on a 1.6Ghz 88f6282 CPU: Each system call is tested in two way (fast/slow): - on the fast version, the tested system call is accepted immediately after checking the architecture (5 BPF instructions). - on the slow version, the tested system call is accepted after previously checking for 85 syscall (90 instructions, including the architecture check). The tested syscall is invoked in a loop 1000000 time, the reported time is the time spent in the loop in seconds. Without Seccomp JIT: Syscall Time-Fast Time-Slow --------------- ---------- ---------- gettimeofday 0.389 1.633 getpid 0.406 1.688 getresuid 1.003 2.266 getcwd 1.342 2.128 With Seccomp JIT: Syscall Time-Fast Time-Slow --------------- ----------- --------- gettimeofday 0.348 0.428 getpid 0.365 0.480 getresuid 0.981 1.060 getcwd 1.237 1.294 For reference, the same code without any seccomp filter: Syscall Time --------------- ----- gettimeofday 0.119 getpid 0.137 getresuid 0.747 getcwd 1.021 The activation of the BPF JIT for seccomp is still controled with the /proc/sys/net/core/bpf_jit_enable sysctl knob. This patch: Architecture must select HAVE_SECCOMP_FILTER_JIT and implement seccomp_jit_compile() and seccomp_jit_free() if they intend to support jitted seccomp filters. Accessors to struct seccomp_filter fields are provided in <linux/seccomp.h> to be used by the JIT code. With this, the 'struct seccomp_filter' structure can stay opaque when outside kernel/seccomp.c. In a way similar to the net BPF, the jit compilation code is expected to updates struct seccomp_filter.bpf_func pointer (using the correct accessor) to the generated code. Signed-off-by: Nicolas Schichan <nschichan@freebox.fr> Cc: Will Drewry <wad@chromium.org> Cc: Mircea Gherzan <mgherzan@gmail.com> Cc: Nicolas Schichan <nschichan@freebox.fr> Cc: Russell King <linux@arm.linux.org.uk> Cc: "David S. Miller" <davem@davemloft.net> Cc: Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/Kconfig14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index 8d2ae24b9f4a..651a9e747ceb 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -332,6 +332,10 @@ config HAVE_ARCH_SECCOMP_FILTER
- secure_computing return value is checked and a return value of -1
results in the system call being skipped immediately.
+# Used by archs to tell that they support SECCOMP_FILTER_JIT
+config HAVE_SECCOMP_FILTER_JIT
+ bool
+
config SECCOMP_FILTER
def_bool y
depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET
@@ -342,6 +346,16 @@ config SECCOMP_FILTER
See Documentation/prctl/seccomp_filter.txt for details.
+config SECCOMP_FILTER_JIT
+ bool "enable Seccomp filter Just In Time compiler"
+ depends on HAVE_SECCOMP_FILTER_JIT && BPF_JIT && SECCOMP_FILTER
+ help
+ Seccomp syscall filtering capabilities are normally handled
+ by an interpreter. This option allows kernel to generate a native
+ code when filter is loaded in memory. This should speedup
+ syscall filtering. Note : Admin should enable this feature
+ changing /proc/sys/net/core/bpf_jit_enable
+
config HAVE_CONTEXT_TRACKING
bool
help