1
0
Fork 0
remarkable-linux/init
Alexei Starovoitov a3d6dd6a66 bpf: introduce BPF_JIT_ALWAYS_ON config
[ upstream commit 290af86629 ]

The BPF interpreter has been used as part of the spectre 2 attack CVE-2017-5715.

A quote from goolge project zero blog:
"At this point, it would normally be necessary to locate gadgets in
the host kernel code that can be used to actually leak data by reading
from an attacker-controlled location, shifting and masking the result
appropriately and then using the result of that as offset to an
attacker-controlled address for a load. But piecing gadgets together
and figuring out which ones work in a speculation context seems annoying.
So instead, we decided to use the eBPF interpreter, which is built into
the host kernel - while there is no legitimate way to invoke it from inside
a VM, the presence of the code in the host kernel's text section is sufficient
to make it usable for the attack, just like with ordinary ROP gadgets."

To make attacker job harder introduce BPF_JIT_ALWAYS_ON config
option that removes interpreter from the kernel in favor of JIT-only mode.
So far eBPF JIT is supported by:
x64, arm64, arm32, sparc64, s390, powerpc64, mips64

The start of JITed program is randomized and code page is marked as read-only.
In addition "constant blinding" can be turned on with net.core.bpf_jit_harden

v2->v3:
- move __bpf_prog_ret0 under ifdef (Daniel)

v1->v2:
- fix init order, test_bpf and cBPF (Daniel's feedback)
- fix offloaded bpf (Jakub's feedback)
- add 'return 0' dummy in case something can invoke prog->bpf_func
- retarget bpf tree. For bpf-next the patch would need one extra hunk.
  It will be sent when the trees are merged back to net-next

Considered doing:
  int bpf_jit_enable __read_mostly = BPF_EBPF_JIT_DEFAULT;
but it seems better to land the patch as-is and in bpf-next remove
bpf_jit_enable global variable from all JITs, consolidate in one place
and remove this jit_init() function.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-31 12:55:56 +01:00
..
Kconfig bpf: introduce BPF_JIT_ALWAYS_ON config 2018-01-31 12:55:56 +01:00
Makefile kbuild: allow archs to select link dead code/data elimination 2016-09-09 10:47:00 +02:00
calibrate.c kernel: add calibration_delay_done() 2014-06-16 12:47:39 -06:00
do_mounts.c init/do_mounts.c: add create_dev() failure log 2015-06-25 17:00:42 -07:00
do_mounts.h init/do_mounts: initrd_load() can be boolean 2016-01-20 17:09:18 -08:00
do_mounts_initrd.c init/do_mounts: initrd_load() can be boolean 2016-01-20 17:09:18 -08:00
do_mounts_md.c init: disable sparse checking of the mount.o source files 2012-05-31 17:49:27 -07:00
do_mounts_rd.c init: use pr_cont() when displaying rotator during ramdisk loading. 2016-11-24 09:32:20 -08:00
init_task.c sched/core: Allow putting thread_info into task_struct 2016-09-15 08:25:13 +02:00
initramfs.c initramfs: finish fput() before accessing any binary from initramfs 2017-10-21 17:21:33 +02:00
main.c kaiser: stack map PAGE_SIZE at THREAD_SIZE-PAGE_SIZE 2018-01-05 15:46:32 +01:00
noinitramfs.c init: mark __user address space on string literals 2010-10-26 16:52:15 -07:00
version.c copy address of proc_ns_ops into ns_common 2014-12-04 14:34:47 -05:00