Skip to content
Commit ecc6a210 authored by Andrei Matei's avatar Andrei Matei Committed by Alexei Starovoitov
Browse files

bpf: Protect against int overflow for stack access size

This patch re-introduces protection against the size of access to stack
memory being negative; the access size can appear negative as a result
of overflowing its signed int representation. This should not actually
happen, as there are other protections along the way, but we should
protect against it anyway. One code path was missing such protections
(fixed in the previous patch in the series), causing out-of-bounds array
accesses in check_stack_range_initialized(). This patch causes the
verification of a program with such a non-sensical access size to fail.

This check used to exist in a more indirect way, but was inadvertendly
removed in a833a17a.

Fixes: a833a17a

 ("bpf: Fix verification of indirect var-off stack access")
Reported-by: default avatar <syzbot+33f4297b5f927648741a@syzkaller.appspotmail.com>
Reported-by: default avatar <syzbot+aafd0513053a1cbf52ef@syzkaller.appspotmail.com>
Closes: https://lore.kernel.org/bpf/CAADnVQLORV5PT0iTAhRER+iLBTkByCYNBYyvBSgjN1T31K+gOw@mail.gmail.com/


Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: default avatarAndrei Matei <andreimatei1@gmail.com>
Link: https://lore.kernel.org/r/20240327024245.318299-3-andreimatei1@gmail.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent a8d89feb
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment