From: Jann Horn Date: Tue, 19 Dec 2017 04:11:57 +0000 (-0800) Subject: bpf: fix missing error return in check_stack_boundary() X-Git-Tag: archive/raspbian/4.15.4-1+rpi1~1^2^2~23 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b051d0a5bca367dbafe5edf8e3aab9c9c9ce59ae;p=linux.git bpf: fix missing error return in check_stack_boundary() Prevent indirect stack accesses at non-constant addresses, which would permit reading and corrupting spilled pointers. Fixes: f1174f77b50c ("bpf/verifier: rework value tracking") Signed-off-by: Jann Horn Signed-off-by: Alexei Starovoitov Signed-off-by: Daniel Borkmann Gbp-Pq: Topic bugfix/all Gbp-Pq: Name bpf-fix-missing-error-return-in-check_stack_boundary.patch --- diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index e6d15c0cf3b..a9f9a5e57ba 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -1320,6 +1320,7 @@ static int check_stack_boundary(struct bpf_verifier_env *env, int regno, tnum_strn(tn_buf, sizeof(tn_buf), regs[regno].var_off); verbose(env, "invalid variable stack read R%d var_off=%s\n", regno, tn_buf); + return -EACCES; } off = regs[regno].off + regs[regno].var_off.value; if (off >= 0 || off < -MAX_BPF_STACK || off + access_size > 0 ||