]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Fix task_local_data data allocation size
authorAmery Hung <ameryhung@gmail.com>
Tue, 31 Mar 2026 21:35:51 +0000 (14:35 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 2 Apr 2026 22:11:08 +0000 (15:11 -0700)
commit7c8ca532a7413b9ecf533d870641e9cff333d685
tree842439fd609ce0d348f21de6bbad4d41fd00fe03
parente8aec1058ca598fe2013ef3489ae729a8070801b
selftests/bpf: Fix task_local_data data allocation size

Currently, when allocating memory for data, size of tld_data_u->start
is not taken into account. This may cause OOB access. Fixed it by adding
the non-flexible array part of tld_data_u.

Besides, explicitly align tld_data_u->data to 8 bytes in case some
fields are added before data in the future. It could break the
assumption that every data field is 8 byte aligned and
sizeof(tld_data_u) will no longer be equal to
offsetof(struct tld_data_u, data), which we use interchangeably.

Signed-off-by: Amery Hung <ameryhung@gmail.com>
Acked-by: Sun Jian <sun.jian.kdev@gmail.com>
Link: https://lore.kernel.org/r/20260331213555.1993883-2-ameryhung@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/task_local_data.h
tools/testing/selftests/bpf/progs/task_local_data.bpf.h