mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
selftests/bpf: Move the no-arena tests out of objects with an arena map
Two programs expect to fail for want of an arena while living next to an arena map: the kfunc argument case in arena_kfunc.c and the scalar access case in verifier_arena_scalar.c. Once libbpf binds the arena of an object to every program in it, they would load. Move them to an object without an arena map ahead of that change, where the kernel checks still apply, so that the tests pass at every step. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261019132203.3034698-11-memxor@gmail.com
This commit is contained in:
parent
1dad22de9c
commit
bc4a327d5b
|
|
@ -3,6 +3,7 @@
|
|||
#include <test_progs.h>
|
||||
|
||||
#include "arena_kfunc.skel.h"
|
||||
#include "arena_noarena.skel.h"
|
||||
#include "arena_kfunc_jit.skel.h"
|
||||
#include "cap_helpers.h"
|
||||
#include "cb_refs.skel.h"
|
||||
|
|
@ -193,6 +194,7 @@ static void run_tests_aux(const char *skel_name,
|
|||
} while (0)
|
||||
|
||||
void test_arena_kfunc(void) { RUN_TESTS(arena_kfunc); }
|
||||
void test_arena_noarena(void) { RUN_TESTS(arena_noarena); }
|
||||
|
||||
void test_arena_kfunc_jit(void) { RUN_TESTS(arena_kfunc_jit); }
|
||||
|
||||
|
|
|
|||
|
|
@ -192,16 +192,6 @@ int arena_arg_unpopulated(void *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
SEC("syscall")
|
||||
__arch_x86_64
|
||||
__arch_arm64
|
||||
__failure __msg("arena pointer requires a program with an associated arena")
|
||||
int arena_arg_no_arena(void *ctx)
|
||||
{
|
||||
bpf_kfunc_arena_arg_test((u64 *)1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SEC("syscall")
|
||||
__arch_x86_64
|
||||
__arch_arm64
|
||||
|
|
|
|||
39
tools/testing/selftests/bpf/progs/arena_noarena.c
Normal file
39
tools/testing/selftests/bpf/progs/arena_noarena.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
|
||||
|
||||
#include <vmlinux.h>
|
||||
#include <bpf/bpf_helpers.h>
|
||||
#include "bpf_misc.h"
|
||||
#include "../test_kmods/bpf_testmod_kfunc.h"
|
||||
|
||||
/*
|
||||
* Programs without an arena. They cannot share an object with an arena map,
|
||||
* libbpf binds the arena of an object to every program in it.
|
||||
*/
|
||||
|
||||
SEC("syscall")
|
||||
__arch_x86_64
|
||||
__arch_arm64
|
||||
__failure __msg("arena pointer requires a program with an associated arena")
|
||||
int arena_arg_no_arena(void *ctx)
|
||||
{
|
||||
bpf_kfunc_arena_arg_test((u64 *)1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SEC("syscall")
|
||||
__flag(BPF_F_ARENA_SCALAR)
|
||||
__arch_x86_64
|
||||
__arch_arm64
|
||||
__description("arena_scalar: no arena, no access through a number")
|
||||
__failure __msg("R6 invalid mem access 'scalar'")
|
||||
__naked void no_arena(void)
|
||||
{
|
||||
asm volatile (" \
|
||||
r6 = 0x100000000000 ll; \
|
||||
r0 = *(u64 *)(r6 + 0); \
|
||||
exit; \
|
||||
" ::: __clobber_all);
|
||||
}
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
|
|
@ -991,19 +991,6 @@ __naked void no_flag(void)
|
|||
: __clobber_all);
|
||||
}
|
||||
|
||||
SEC("syscall")
|
||||
__arena_scalar
|
||||
__description("arena_scalar: no arena, no access through a number")
|
||||
__failure __msg("R6 invalid mem access 'scalar'")
|
||||
__naked void no_arena(void)
|
||||
{
|
||||
asm volatile (" \
|
||||
r6 = 0x100000000000 ll; \
|
||||
r0 = *(u64 *)(r6 + 0); \
|
||||
exit; \
|
||||
" ::: __clobber_all);
|
||||
}
|
||||
|
||||
SEC("syscall")
|
||||
__arena_scalar
|
||||
__description("arena_scalar: pointer that is NULL is an address in arena")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user