From: Martin KaFai Lau <martin.lau@xxxxxxxxxx> 'struct bpf_local_storage_elem' has a 56 bytes padding at the end which can be used for attr->value_size. The current smap->elem_size calculation is unnecessarily inflated by 56 bytes. The patch is to fix it by calculating the smap->elem_size with offsetof(). Signed-off-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx> --- kernel/bpf/bpf_local_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/bpf_local_storage.c b/kernel/bpf/bpf_local_storage.c index b39a46e8fb08..cb43e70613b1 100644 --- a/kernel/bpf/bpf_local_storage.c +++ b/kernel/bpf/bpf_local_storage.c @@ -580,8 +580,8 @@ static struct bpf_local_storage_map *__bpf_local_storage_map_alloc(union bpf_att raw_spin_lock_init(&smap->buckets[i].lock); } - smap->elem_size = - sizeof(struct bpf_local_storage_elem) + attr->value_size; + smap->elem_size = offsetof(struct bpf_local_storage_elem, sdata) + + offsetof(struct bpf_local_storage_data, data[attr->value_size]); return smap; } -- 2.30.2