android_kernel_oneplus_msm8998/kernel/bpf
Daniel Borkmann 49630dd2e1 bpf: don't let ldimm64 leak map addresses on unprivileged
commit 0d0e57697f162da4aa218b5feafe614fb666db07 upstream.

The patch fixes two things at once:

1) It checks the env->allow_ptr_leaks and only prints the map address to
   the log if we have the privileges to do so, otherwise it just dumps 0
   as we would when kptr_restrict is enabled on %pK. Given the latter is
   off by default and not every distro sets it, I don't want to rely on
   this, hence the 0 by default for unprivileged.

2) Printing of ldimm64 in the verifier log is currently broken in that
   we don't print the full immediate, but only the 32 bit part of the
   first insn part for ldimm64. Thus, fix this up as well; it's okay to
   access, since we verified all ldimm64 earlier already (including just
   constants) through replace_map_fd_with_map_ptr().

Fixes: 1be7f75d16 ("bpf: enable non-root eBPF programs")
Fixes: cbd3570086 ("bpf: verifier (add ability to receive verification log)")
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 4.4: s/bpf_verifier_env/verifier_env/]
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-21 09:21:17 +01:00
..
arraymap.c bpf: fix allocation warnings in bpf maps and integer overflow 2015-12-02 23:36:00 -05:00
core.c bpf: consolidate bpf_prog_put{, _rcu} dismantle paths 2015-11-02 22:48:39 -05:00
hashtab.c bpf: fix allocation warnings in bpf maps and integer overflow 2015-12-02 23:36:00 -05:00
helpers.c bpf: avoid copying junk bytes in bpf_get_current_comm() 2016-04-20 15:42:01 +09:00
inode.c bpf, inode: disallow userns mounts 2016-06-24 10:18:17 -07:00
Makefile bpf: add support for persistent maps/progs 2015-11-02 22:48:39 -05:00
syscall.c bpf: fix refcnt overflow 2016-05-18 17:06:37 -07:00
verifier.c bpf: don't let ldimm64 leak map addresses on unprivileged 2017-11-21 09:21:17 +01:00