diff options
| author | Ilya Leoshkevich <iii@linux.ibm.com> | 2025-08-13 14:06:31 +0200 |
|---|---|---|
| committer | Daniel Borkmann <daniel@iogearbox.net> | 2025-08-18 15:08:30 +0200 |
| commit | 12741630350c6ba250ffd480dbb0bbab7e8ac80a (patch) | |
| tree | 36c9cb58b064bcfa1ea16d196950734a3599c740 /tools/testing/selftests/bpf/progs/bpf_test_utils.h | |
| parent | s390/bpf: Write back tail call counter for BPF_TRAMP_F_CALL_ORIG (diff) | |
| download | linux-12741630350c6ba250ffd480dbb0bbab7e8ac80a.tar.gz linux-12741630350c6ba250ffd480dbb0bbab7e8ac80a.zip | |
selftests/bpf: Clobber a lot of registers in tailcall_bpf2bpf_hierarchy tests
Clobbering a lot of registers and stack slots helps exposing tail call
counter overwrite bugs in JITs.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20250813121016.163375-5-iii@linux.ibm.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs/bpf_test_utils.h')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/bpf_test_utils.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/bpf_test_utils.h b/tools/testing/selftests/bpf/progs/bpf_test_utils.h new file mode 100644 index 000000000000..f4e67b492dd2 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/bpf_test_utils.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __BPF_TEST_UTILS_H__ +#define __BPF_TEST_UTILS_H__ + +#include <bpf/bpf_helpers.h> +#include "bpf_misc.h" + +/* Clobber as many native registers and stack slots as possible. */ +static __always_inline void clobber_regs_stack(void) +{ + char tmp_str[] = "123456789"; + unsigned long tmp; + + bpf_strtoul(tmp_str, sizeof(tmp_str), 0, &tmp); + __sink(tmp); +} + +#endif |
