diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2023-09-13 01:32:13 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-09-16 09:36:43 -0700 |
commit | d6ea06803212d992cbab24466f491ee0178bf9e0 (patch) | |
tree | 234281c42752e29dacdf14233a7755ce50ae7bbe /tools/testing/selftests/bpf/progs/exceptions_fail.c | |
parent | 7e2925f6723702bcfcfdf8f73d5e85f7514d4b9f (diff) |
selftests/bpf: Add BPF assertion macros
Add macros implementing an 'assert' statement primitive using macros,
built on top of the BPF exceptions support introduced in previous
patches.
The bpf_assert_*_with variants allow supplying a value which can the be
inspected within the exception handler to signify the assert statement
that led to the program being terminated abruptly, or be returned by the
default exception handler.
Note that only 64-bit scalar values are supported with these assertion
macros, as during testing I found other cases quite unreliable in
presence of compiler shifts/manipulations extracting the value of the
right width from registers scrubbing the verifier's bounds information
and knowledge about the value in the register.
Thus, it is easier to reliably support this feature with only the full
register width, and support both signed and unsigned variants.
The bpf_assert_range is interesting in particular, which clamps the
value in the [begin, end] (both inclusive) range within verifier state,
and emits a check for the same at runtime.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230912233214.1518551-17-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/exceptions_fail.c')
0 files changed, 0 insertions, 0 deletions