mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
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>
This commit is contained in:
committed by
Alexei Starovoitov
parent
e8aec1058c
commit
7c8ca532a7
@@ -87,7 +87,7 @@ struct tld_meta_u {
|
||||
|
||||
struct tld_data_u {
|
||||
__u64 start; /* offset of tld_data_u->data in a page */
|
||||
char data[__PAGE_SIZE - sizeof(__u64)];
|
||||
char data[__PAGE_SIZE - sizeof(__u64)] __attribute__((aligned(8)));
|
||||
};
|
||||
|
||||
struct tld_map_value {
|
||||
|
||||
Reference in New Issue
Block a user