mirror-linux/kernel/bpf
Stanislav Fomichev 551a26668c bpf: Don't EFAULT for getsockopt with optval=NULL
[ Upstream commit 00e74ae086 ]

Some socket options do getsockopt with optval=NULL to estimate the size
of the final buffer (which is returned via optlen). This breaks BPF
getsockopt assumptions about permitted optval buffer size. Let's enforce
these assumptions only when non-NULL optval is provided.

Fixes: 0d01da6afc ("bpf: implement getsockopt and setsockopt hooks")
Reported-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/ZD7Js4fj5YyI2oLd@google.com/T/#mb68daf700f87a9244a15d01d00c3f0e5b08f49f7
Link: https://lore.kernel.org/bpf/20230418225343.553806-2-sdf@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-11 23:03:26 +09:00
..
preload
Kconfig
Makefile
arraymap.c
bloom_filter.c
bpf_inode_storage.c
bpf_iter.c
bpf_local_storage.c
bpf_lru_list.c
bpf_lru_list.h
bpf_lsm.c bpf: Fix the kernel crash caused by bpf_setsockopt(). 2023-02-09 11:28:02 +01:00
bpf_struct_ops.c
bpf_struct_ops_types.h
bpf_task_storage.c
btf.c bpf: Fix race between btf_put and btf_idr walk. 2023-05-11 23:03:26 +09:00
cgroup.c bpf: Don't EFAULT for getsockopt with optval=NULL 2023-05-11 23:03:26 +09:00
cgroup_iter.c
core.c bpf: Adjust insufficient default bpf_jit_limit 2023-03-30 12:49:08 +02:00
cpumap.c
devmap.c
disasm.c
disasm.h
dispatcher.c
hashtab.c bpf: Zeroing allocated object from slab in bpf memory allocator 2023-03-10 09:33:06 +01:00
helpers.c
inode.c
link_iter.c
local_storage.c
lpm_trie.c
map_in_map.c
map_in_map.h
map_iter.c
memalloc.c bpf: Zeroing allocated object from slab in bpf memory allocator 2023-03-10 09:33:06 +01:00
mmap_unlock_work.h
net_namespace.c
offload.c
percpu_freelist.c
percpu_freelist.h
prog_iter.c
queue_stack_maps.c
reuseport_array.c
ringbuf.c
stackmap.c
syscall.c
sysfs_btf.c
task_iter.c
tnum.c
trampoline.c
verifier.c bpf: Fix __reg_bound_offset 64->32 var_off subreg propagation 2023-05-11 23:03:19 +09:00