From: Jann Horn Date: Tue, 19 Dec 2017 04:11:58 +0000 (-0800) Subject: bpf: force strict alignment checks for stack pointers X-Git-Tag: archive/raspbian/4.15.4-1+rpi1~1^2^2~22 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c4832039dcfbef771a8b58b79fa7254121192eb2;p=linux.git bpf: force strict alignment checks for stack pointers Force strict alignment checks for stack pointers because the tracking of stack spills relies on it; unaligned stack accesses can lead to corruption of spilled registers, which is exploitable. 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-force-strict-alignment-checks-for-stack-pointers.patch --- diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index a9f9a5e57ba..7d7adf3fb89 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -1071,6 +1071,11 @@ static int check_ptr_alignment(struct bpf_verifier_env *env, break; case PTR_TO_STACK: pointer_desc = "stack "; + /* The stack spill tracking logic in check_stack_write() + * and check_stack_read() relies on stack accesses being + * aligned. + */ + strict = true; break; default: break;