Skip to content

Commit 2431646

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
selftests/bpf: validate .bss section bigger than 8MB is possible now
Add a simple big 16MB array and validate access to the very last byte of it to make sure that kernel supports > KMALLOC_MAX_SIZE value_size for BPF array maps (which are backing .bss in this case). Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 63b8ce7 commit 2431646

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

tools/testing/selftests/bpf/prog_tests/skeleton.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ void test_skeleton(void)
122122

123123
ASSERT_EQ(skel->bss->out_mostly_var, 123, "out_mostly_var");
124124

125+
ASSERT_EQ(bss->huge_arr[ARRAY_SIZE(bss->huge_arr) - 1], 123, "huge_arr");
126+
125127
elf_bytes = test_skeleton__elf_bytes(&elf_bytes_sz);
126128
ASSERT_OK_PTR(elf_bytes, "elf_bytes");
127129
ASSERT_GE(elf_bytes_sz, 0, "elf_bytes_sz");

tools/testing/selftests/bpf/progs/test_skeleton.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ int out_dynarr[4] SEC(".data.dyn") = { 1, 2, 3, 4 };
5151
int read_mostly_var __read_mostly;
5252
int out_mostly_var;
5353

54+
char huge_arr[16 * 1024 * 1024];
55+
5456
SEC("raw_tp/sys_enter")
5557
int handler(const void *ctx)
5658
{
@@ -71,6 +73,8 @@ int handler(const void *ctx)
7173

7274
out_mostly_var = read_mostly_var;
7375

76+
huge_arr[sizeof(huge_arr) - 1] = 123;
77+
7478
return 0;
7579
}
7680

0 commit comments

Comments
 (0)