]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix mask direction swap upon off reg sign change
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 21 May 2021 10:19:22 +0000 (10:19 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 25 May 2021 20:08:53 +0000 (22:08 +0200)
commitb671acde4d0e90b0d0062043f1e78f5e63381088
tree2a55730fe2493fef3e9067069bed9a5a89bc5ae7
parent48586f4cd94c1102d8c3ec238c06316425e1f0ff
bpf: Fix mask direction swap upon off reg sign change

Masking direction as indicated via mask_to_left is considered to be
calculated once and then used to derive pointer limits. Thus, this
needs to be placed into bpf_sanitize_info instead so we can pass it
to sanitize_ptr_alu() call after the pointer move. Piotr noticed a
corner case where the off reg causes masking direction change which
then results in an incorrect final aux->alu_limit.

Fixes: 430d9c6a851c ("bpf: Tighten speculative pointer arithmetic mask")
Reported-by: Piotr Krysiuk <piotras@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Piotr Krysiuk <piotras@gmail.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c