Skip to content

Commit

Permalink
selftests/bpf: validate .bss section bigger than 8MB is possible now
Browse files Browse the repository at this point in the history
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 <andrii@kernel.org>
Link: https://lore.kernel.org/r/20220715053146.1291891-5-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
anakryiko authored and Alexei Starovoitov committed Jul 19, 2022
1 parent 63b8ce7 commit 2431646
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/skeleton.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ void test_skeleton(void)

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

ASSERT_EQ(bss->huge_arr[ARRAY_SIZE(bss->huge_arr) - 1], 123, "huge_arr");

elf_bytes = test_skeleton__elf_bytes(&elf_bytes_sz);
ASSERT_OK_PTR(elf_bytes, "elf_bytes");
ASSERT_GE(elf_bytes_sz, 0, "elf_bytes_sz");
Expand Down
4 changes: 4 additions & 0 deletions tools/testing/selftests/bpf/progs/test_skeleton.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ int out_dynarr[4] SEC(".data.dyn") = { 1, 2, 3, 4 };
int read_mostly_var __read_mostly;
int out_mostly_var;

char huge_arr[16 * 1024 * 1024];

SEC("raw_tp/sys_enter")
int handler(const void *ctx)
{
Expand All @@ -71,6 +73,8 @@ int handler(const void *ctx)

out_mostly_var = read_mostly_var;

huge_arr[sizeof(huge_arr) - 1] = 123;

return 0;
}

Expand Down

0 comments on commit 2431646

Please sign in to comment.