linux/arch/arm
Daniel Borkmann 60a3b2253c net: bpf: make eBPF interpreter images read-only
With eBPF getting more extended and exposure to user space is on it's way,
hardening the memory range the interpreter uses to steer its command flow
seems appropriate.  This patch moves the to be interpreted bytecode to
read-only pages.

In case we execute a corrupted BPF interpreter image for some reason e.g.
caused by an attacker which got past a verifier stage, it would not only
provide arbitrary read/write memory access but arbitrary function calls
as well. After setting up the BPF interpreter image, its contents do not
change until destruction time, thus we can setup the image on immutable
made pages in order to mitigate modifications to that code. The idea
is derived from commit 314beb9bca ("x86: bpf_jit_comp: secure bpf jit
against spraying attacks").

This is possible because bpf_prog is not part of sk_filter anymore.
After setup bpf_prog cannot be altered during its life-time. This prevents
any modifications to the entire bpf_prog structure (incl. function/JIT
image pointer).

Every eBPF program (including classic BPF that are migrated) have to call
bpf_prog_select_runtime() to select either interpreter or a JIT image
as a last setup step, and they all are being freed via bpf_prog_free(),
including non-JIT. Therefore, we can easily integrate this into the
eBPF life-time, plus since we directly allocate a bpf_prog, we have no
performance penalty.

Tested with seccomp and test_bpf testsuite in JIT/non-JIT mode and manual
inspection of kernel_page_tables.  Brad Spengler proposed the same idea
via Twitter during development of this patch.

Joint work with Hannes Frederic Sowa.

Suggested-by: Brad Spengler <spender@grsecurity.net>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Kees Cook <keescook@chromium.org>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-09-05 12:02:48 -07:00
..
boot The branch contains the following device tree changes the v3.17 merge 2014-08-14 09:53:39 -06:00
common Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma 2014-08-11 07:14:01 -07:00
configs ARM: SoC defconfig updates for 3.17 2014-08-08 11:35:11 -07:00
crypto Merge branch 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm 2014-08-05 10:05:29 -07:00
firmware
include ARM: wire up memfd_create syscall 2014-08-09 14:07:59 +01:00
kernel Nicolas Pitre added generic tracepoints for tracing IPIs and updated the 2014-08-09 17:33:44 -07:00
kvm Here are the PPC and ARM changes for KVM, which I separated because 2014-08-07 11:35:30 -07:00
lib ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-at91 This is the bulk of GPIO changes for the v3.17 development 2014-08-08 18:00:35 -07:00
mach-axxia
mach-bcm ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-berlin
mach-clps711x ARM: SoC cleanups for 3.17 2014-08-08 11:00:26 -07:00
mach-cns3xxx
mach-davinci
mach-dove
mach-ebsa110 ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-efm32
mach-ep93xx ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-exynos ARM: EXYNOS: Fix suspend/resume sequences 2014-08-09 08:24:36 -07:00
mach-footbridge ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-gemini
mach-highbank
mach-hisi ARM: hisi: remove smp from machine descriptor 2014-07-30 22:32:21 -07:00
mach-imx ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-integrator ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-iop13xx ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-iop32x
mach-iop33x
mach-ixp4xx
mach-keystone
mach-ks8695 ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-lpc32xx
mach-mediatek
mach-mmp
mach-moxart
mach-msm Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2014-08-06 21:03:53 -07:00
mach-mv78xx0
mach-mvebu ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-mxs
mach-netx
mach-nomadik
mach-nspire
mach-omap1 ARM: SoC cleanups for 3.17 2014-08-08 11:00:26 -07:00
mach-omap2 Few fixes for the v3.17 merge window: 2014-08-09 08:23:27 -07:00
mach-orion5x
mach-picoxcell
mach-prima2
mach-pxa Merge branch 'akpm' (second patchbomb from Andrew Morton) 2014-08-08 15:57:47 -07:00
mach-qcom
mach-realview ARM: SoC cleanups for 3.17 2014-08-08 11:00:26 -07:00
mach-rockchip ARM: SoC device-tree changes for 3.17 2014-08-08 11:16:58 -07:00
mach-rpc ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-s3c24xx Merge branch 'akpm' (second patchbomb from Andrew Morton) 2014-08-08 15:57:47 -07:00
mach-s3c64xx
mach-s5pv210 ARM: SoC cleanups for 3.17 2014-08-08 11:00:26 -07:00
mach-sa1100 ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-shmobile ARM: SoC device-tree changes for 3.17 2014-08-08 11:16:58 -07:00
mach-socfpga
mach-spear ARM: SoC driver changes for 3.17 2014-08-08 11:34:32 -07:00
mach-sti
mach-sunxi ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-tegra This is the bulk of GPIO changes for the v3.17 development 2014-08-08 18:00:35 -07:00
mach-u300
mach-ux500
mach-versatile ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-vexpress ARM: SoC cleanups for 3.17 2014-08-08 11:00:26 -07:00
mach-vt8500
mach-w90x900 arch/arm/mach-w90x900/cpu.c: replace obsolete strict_strto 2014-08-08 15:57:28 -07:00
mach-zynq
mm ARM: 8114/1: LPAE: load upper bits of early TTBR0/TTBR1 2014-08-09 08:42:12 +01:00
net net: bpf: make eBPF interpreter images read-only 2014-09-05 12:02:48 -07:00
nwfpe
oprofile Merge branch 'devel-stable' into for-next 2014-08-05 10:27:25 +01:00
plat-iop
plat-omap ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
plat-orion
plat-pxa
plat-samsung
plat-versatile
tools
vfp
xen arm/xen: remove duplicate arch_gnttab_init() function 2014-08-11 11:59:14 +01:00
Kconfig Merge branch 'akpm' (second patchbomb from Andrew Morton) 2014-08-08 15:57:47 -07:00
Kconfig-nommu
Kconfig.debug ARM: SoC device-tree changes for 3.17 2014-08-08 11:16:58 -07:00
Makefile ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00