diff options
author | Hou Tao <[email protected]> | 2023-09-28 18:15:58 +0800 |
---|---|---|
committer | Alexei Starovoitov <[email protected]> | 2023-09-30 09:39:28 -0700 |
commit | 9077fc228f09c9f975c498c55f5d2e882cd0da59 (patch) | |
tree | 0c0d572e4a039931672948678ebb10bd833e9db4 /lib/test_fortify/write_overflow-strncpy-src.c | |
parent | d1a783daa443d34e2f39811573ac9cbb5e5b78f3 (diff) |
bpf: Use kmalloc_size_roundup() to adjust size_index
Commit d52b59315bf5 ("bpf: Adjust size_index according to the value of
KMALLOC_MIN_SIZE") uses KMALLOC_MIN_SIZE to adjust size_index, but as
reported by Nathan, the adjustment is not enough, because
__kmalloc_minalign() also decides the minimal alignment of slab object
as shown in new_kmalloc_cache() and its value may be greater than
KMALLOC_MIN_SIZE (e.g., 64 bytes vs 8 bytes under a riscv QEMU VM).
Instead of invoking __kmalloc_minalign() in bpf subsystem to find the
maximal alignment, just using kmalloc_size_roundup() directly to get the
corresponding slab object size for each allocation size. If these two
sizes are unmatched, adjust size_index to select a bpf_mem_cache with
unit_size equal to the object_size of the underlying slab cache for the
allocation size.
Fixes: 822fb26bdb55 ("bpf: Add a hint to allocated objects.")
Reported-by: Nathan Chancellor <[email protected]>
Closes: https://lore.kernel.org/bpf/[email protected]/
Signed-off-by: Hou Tao <[email protected]>
Tested-by: Emil Renner Berthing <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'lib/test_fortify/write_overflow-strncpy-src.c')
0 files changed, 0 insertions, 0 deletions