Skip to content

Commit 63b8ce7

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
bpf: remove obsolete KMALLOC_MAX_SIZE restriction on array map value size
Syscall-side map_lookup_elem() and map_update_elem() used to use kmalloc() to allocate temporary buffers of value_size, so KMALLOC_MAX_SIZE limit on value_size made sense to prevent creation of array map that won't be accessible through syscall interface. But this limitation since has been lifted by relying on kvmalloc() in syscall handling code. So remove KMALLOC_MAX_SIZE, which among other things means that it's possible to have BPF global variable sections (.bss, .data, .rodata) bigger than 8MB now. Keep the sanity check to prevent trivial overflows like round_up(map->value_size, 8) and restrict value size to <= INT_MAX (2GB). Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent d937bc3 commit 63b8ce7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

kernel/bpf/arraymap.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ int array_map_alloc_check(union bpf_attr *attr)
7070
attr->map_flags & BPF_F_PRESERVE_ELEMS)
7171
return -EINVAL;
7272

73-
if (attr->value_size > KMALLOC_MAX_SIZE)
74-
/* if value_size is bigger, the user space won't be able to
75-
* access the elements.
76-
*/
73+
/* avoid overflow on round_up(map->value_size) */
74+
if (attr->value_size > INT_MAX)
7775
return -E2BIG;
7876

7977
return 0;

0 commit comments

Comments
 (0)