bpf: Simplify alu_limit masking for pointer arithmetic
authorPiotr Krysiuk <piotras@gmail.com>
Tue, 16 Mar 2021 07:26:25 +0000 (08:26 +0100)
committerCosmin Tanislav <demonsingur@gmail.com>
Thu, 16 May 2024 07:58:23 +0000 (10:58 +0300)
commite038e0f39d14935a04eac77a45ff2279e49b18f6
tree79bcdf2650f19dcc549227aa06cd0b3d554ec15e
parentfb17afdf99e33e3f5f39b5688a5e04162d7afce1
bpf: Simplify alu_limit masking for pointer arithmetic

commit b5871dca250cd391885218b99cc015aca1a51aea upstream.

Instead of having the mov32 with aux->alu_limit - 1 immediate, move this
operation to retrieve_ptr_limit() instead to simplify the logic and to
allow for subsequent sanity boundary checks inside retrieve_ptr_limit().
This avoids in future that at the time of the verifier masking rewrite
we'd run into an underflow which would not sign extend due to the nature
of mov32 instruction.

Signed-off-by: Piotr Krysiuk <piotras@gmail.com>
Co-developed-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/verifier.c