mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-13 00:00:00 -04:00
UPSTREAM: bpf: Fix handling of XADD on BTF memory
check_xadd() can cause check_ptr_to_btf_access() to be executed with
atype==BPF_READ and value_regno==-1 (meaning "just check whether the access
is okay, don't tell me what type it will result in").
Handle that case properly and skip writing type information, instead of
indexing into the registers at index -1 and writing into out-of-bounds
memory.
Note that at least at the moment, you can't actually write through a BTF
pointer, so check_xadd() will reject the program after calling
check_ptr_to_btf_access with atype==BPF_WRITE; but that's after the
verifier has already corrupted memory.
This patch assumes that BTF pointers are not available in unprivileged
programs.
Fixes: 9e15db66136a ("bpf: Implement accurate raw_tp context access via BTF")
Change-Id: I2ed166b1e9772e1dbe7a687380bfb0b0a05f82b8
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200417000007.10734-2-jannh@google.com
This commit is contained in:
parent
05e1dd2156
commit
b5ec6e732f
1 changed files with 1 additions and 1 deletions
|
|
@ -3126,7 +3126,7 @@ static int check_ptr_to_btf_access(struct bpf_verifier_env *env,
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (atype == BPF_READ) {
|
||||
if (atype == BPF_READ && value_regno >= 0) {
|
||||
if (ret == SCALAR_VALUE) {
|
||||
mark_reg_unknown(env, regs, value_regno);
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue