bpf: Fix error message on kfunc arg type mismatch
authorMaxim Mikityanskiy <maxtram95@gmail.com>
Mon, 9 Sep 2024 13:39:09 +0000 (16:39 +0300)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 9 Sep 2024 22:58:17 +0000 (15:58 -0700)
commitbee109b7b3e50739b88252a219fa07ecd78ad628
treededdf35e7e450e37bf4658bb000be9a9baa38452
parentf028d7716cdeae3be7d8d211482248916b25b1c2
bpf: Fix error message on kfunc arg type mismatch

When "arg#%d expected pointer to ctx, but got %s" error is printed, both
template parts actually point to the type of the argument, therefore, it
will also say "but got PTR", regardless of what was the actual register
type.

Fix the message to print the register type in the second part of the
template, change the existing test to adapt to the new format, and add a
new test to test the case when arg is a pointer to context, but reg is a
scalar.

Fixes: 00b85860feb8 ("bpf: Rewrite kfunc argument handling")
Signed-off-by: Maxim Mikityanskiy <maxim@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/bpf/20240909133909.1315460-1-maxim@isovalent.com
kernel/bpf/verifier.c
tools/testing/selftests/bpf/prog_tests/kfunc_call.c
tools/testing/selftests/bpf/progs/kfunc_call_fail.c
tools/testing/selftests/bpf/verifier/calls.c