Kumar Kartikeya Dwivedi e1fad0ff46 bpf: Disallow negative offset in check_ptr_off_reg
check_ptr_off_reg only allows fixed offset to be set for PTR_TO_BTF_ID,
where reg->off < 0 doesn't make sense. This would shift the pointer
backwards, and fails later in btf_struct_ids_match or btf_struct_walk
due to out of bounds access (since offset is interpreted as unsigned).

Improve the verifier by rejecting this case by using a better error
message for BPF helpers and kfunc, by putting a check inside the
check_func_arg_reg_off function.

Also, update existing verifier selftests to work with new error string.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220304224645.3677453-4-memxor@gmail.com
2022-03-05 15:29:35 -08:00
..
2022-02-23 15:17:51 -08:00
2022-03-05 15:29:35 -08:00
2022-02-23 15:17:51 -08:00
2020-03-13 12:49:52 -07:00
2022-02-23 15:17:51 -08:00
2022-02-23 15:17:51 -08:00
2022-02-23 15:17:51 -08:00
2021-07-15 22:31:10 +02:00
2020-08-28 15:41:30 +02:00
2021-12-18 13:27:41 -08:00
2022-02-23 15:17:51 -08:00
2022-02-28 18:10:28 +01:00
2022-02-23 15:17:51 -08:00
2021-11-12 10:19:09 -08:00
2022-02-23 15:17:51 -08:00