mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
selftests/bpf: Remove tests for arena access through numbers
With BPF_F_ARENA_SCALAR the verifier accepts a load or a store through a scalar as an access to arena. The next patch removes the flag. Remove its tests. Keep one test. Without the flag the verifier must reject such a load, also in a prog that has an arena. Move this test to verifier_arena.c. The removed tests were the only tests of a special path in the x86 JIT for the fetching AND/OR/XOR atomics. Only the flag used that path. arena_atomics tests the usual path. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-5-alexei.starovoitov@gmail.com
This commit is contained in:
parent
58cbd31c39
commit
fe8e06aa05
|
|
@ -1,21 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <test_progs.h>
|
||||
#include "sysctl_helpers.h"
|
||||
#include "verifier_arena_scalar.skel.h"
|
||||
|
||||
/* The same tests with constants of the programs blinded */
|
||||
void serial_test_arena_scalar_blinded(void)
|
||||
{
|
||||
const char *harden = "/proc/sys/net/core/bpf_jit_harden";
|
||||
char old[16] = {};
|
||||
|
||||
if (!is_jit_enabled()) {
|
||||
test__skip();
|
||||
return;
|
||||
}
|
||||
if (sysctl_set_or_fail(harden, old, "2"))
|
||||
return;
|
||||
RUN_TESTS(verifier_arena_scalar);
|
||||
sysctl_set_or_fail(harden, NULL, old);
|
||||
}
|
||||
|
|
@ -13,7 +13,6 @@
|
|||
#include "verifier_and.skel.h"
|
||||
#include "verifier_arena.skel.h"
|
||||
#include "verifier_arena_large.skel.h"
|
||||
#include "verifier_arena_scalar.skel.h"
|
||||
#include "verifier_arena_globals1.skel.h"
|
||||
#include "verifier_arena_globals2.skel.h"
|
||||
#include "verifier_array_access.skel.h"
|
||||
|
|
@ -207,7 +206,6 @@ void test_verifier_align(void) { RUN(verifier_align); }
|
|||
void test_verifier_and(void) { RUN(verifier_and); }
|
||||
void test_verifier_arena(void) { RUN(verifier_arena); }
|
||||
void test_verifier_arena_large(void) { RUN(verifier_arena_large); }
|
||||
void test_verifier_arena_scalar(void) { RUN(verifier_arena_scalar); }
|
||||
void test_verifier_arena_globals1(void) { RUN(verifier_arena_globals1); }
|
||||
void test_verifier_arena_globals2(void) { RUN(verifier_arena_globals2); }
|
||||
void test_verifier_basic_stack(void) { RUN(verifier_basic_stack); }
|
||||
|
|
|
|||
|
|
@ -21,19 +21,4 @@ int arena_arg_no_arena(void *ctx)
|
|||
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";
|
||||
|
|
|
|||
|
|
@ -610,6 +610,21 @@ int mixed_arena_scalar_alu64_arena_first(void *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
SEC("syscall")
|
||||
__description("arena: a number is not an address in arena")
|
||||
__failure __msg("R6 invalid mem access 'scalar'")
|
||||
__naked void access_through_number(void)
|
||||
{
|
||||
asm volatile (" \
|
||||
r1 = %[arena] ll; \
|
||||
r6 = 0x100000000000 ll; \
|
||||
r0 = *(u64 *)(r6 + 0); \
|
||||
exit; \
|
||||
" :
|
||||
: __imm_addr(arena)
|
||||
: __clobber_all);
|
||||
}
|
||||
|
||||
SEC("syscall")
|
||||
__success __retval(0)
|
||||
int scalar_xor_arena_ptr(void *ctx)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -590,8 +590,6 @@ static int parse_test_spec(struct test_loader *tester,
|
|||
update_flags(&spec->prog_flags, BPF_F_XDP_HAS_FRAGS, clear);
|
||||
} else if (strcmp(val, "BPF_F_TEST_REG_INVARIANTS") == 0) {
|
||||
update_flags(&spec->prog_flags, BPF_F_TEST_REG_INVARIANTS, clear);
|
||||
} else if (strcmp(val, "BPF_F_ARENA_SCALAR") == 0) {
|
||||
update_flags(&spec->prog_flags, BPF_F_ARENA_SCALAR, clear);
|
||||
} else /* assume numeric value */ {
|
||||
err = parse_int(val, &flags, "test prog flags");
|
||||
if (err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user