Skip to content

Limit local storage value size to max kmalloc_nolock() allocation

Jonathan Bastari Thamrin b4-sent bpf linux-kselftest lkml 1 version New

Get series with b4
b4 am [email protected] change-id 20261104-local-storage-max-c3709fcd6fbc

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: Limit local storage value size to max kmalloc_nolock() allocationinclude/linux/bpf_local_storage.h kernel/bpf/local_storage.c+16 -70 replies
2/2selftests/bpf: Test local storage max value sizetools/testing/selftests/bpf/prog_tests/task_local_storage.c+87 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 0/2] Limit local storage value size to max kmalloc_nolock() allocation

BPF local storage elements are allocated using kmalloc_nolock() but map creation is still allowed with values up to kmalloc()'s larger limit. BPF_LOCAL_STORAGE_MAX_VALUE_SIZE is changed to be based on KMALLOC_MAX_CACHE_SIZE instead and maps with larger values fail on creation with E2BIG. Cgroup storage (BPF_MAP_TYPE_CGROUP_STORAGE) uses the previous limit since it allocates with kmalloc().

A selftest is also added to both find the largest task storage size and test that this value can be stored. It also checks that the size is at least 4096 to check that the limit isn't too low.

---
Jonathan Bastari Thamrin (2):
bpf: Limit local storage value size to max kmalloc_nolock() allocation selftests/bpf: Test local storage max value size

 include/linux/bpf_local_storage.h                  | 10 +--
 kernel/bpf/local_storage.c                         | 13 +++-
 .../selftests/bpf/prog_tests/task_local_storage.c  | 87 ++++++++++++++++++++++
 3 files changed, 103 insertions(+), 7 deletions(-)

---
base-commit: d346f59069676eda84b3313cbd2c2ab21045d3ee
change-id: 20261104-local-storage-max-c3709fcd6fbc

Best regards,

Signature · 1 line
Jonathan Bastari Thamrin <[email protected]>