linux-stable/kernel/bpf
Stanislav Fomichev 8913abddad 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:00:30 +09:00
..
preload
arraymap.c bpf: Acquire map uref in .init_seq_private for array map iterator 2022-08-25 11:40:03 +02:00
bpf_inode_storage.c
bpf_iter.c bpf: Refactor BPF_PROG_RUN into a function 2021-08-17 00:45:07 +02:00
bpf_local_storage.c bpf: Do not copy spin lock field from user in bpf_selem_alloc 2022-12-08 11:28:39 +01:00
bpf_lru_list.c
bpf_lru_list.h
bpf_lsm.c
bpf_struct_ops.c bpf: Handle return value of BPF_PROG_TYPE_STRUCT_OPS prog 2021-09-14 11:09:50 -07:00
bpf_struct_ops_types.h
bpf_task_storage.c bpf: Use this_cpu_{inc|dec|inc_return} for bpf_task_storage_busy 2022-10-26 12:34:41 +02:00
btf.c btf: fix resolving BTF_KIND_VAR after ARRAY, STRUCT, UNION, PTR 2023-03-17 08:48:55 +01:00
cgroup.c bpf: Don't EFAULT for getsockopt with optval=NULL 2023-05-11 23:00:30 +09:00
core.c bpf: Adjust insufficient default bpf_jit_limit 2023-03-30 12:47:47 +02:00
cpumap.c
devmap.c
disasm.c bpf: Relicense disassembler as GPL-2.0-only OR BSD-2-Clause 2021-09-02 14:49:23 +02:00
disasm.h bpf: Relicense disassembler as GPL-2.0-only OR BSD-2-Clause 2021-09-02 14:49:23 +02:00
dispatcher.c
hashtab.c bpf: hash map, avoid deadlock with suitable hash mask 2023-04-13 16:48:16 +02:00
helpers.c bpf: Add MEM_RDONLY for helper args that are pointers to rdonly mem. 2022-05-01 17:22:26 +02:00
inode.c bpf: Fix mount source show for bpffs 2022-01-27 11:05:26 +01:00
Kconfig
local_storage.c
lpm_trie.c
Makefile
map_in_map.c
map_in_map.h
map_iter.c bpf: Introduce MEM_RDONLY flag 2022-05-01 17:22:24 +02:00
net_namespace.c
offload.c bpf: restore the ebpf program ID for BPF_AUDIT_UNLOAD and PERF_BPF_EVENT_PROG_UNLOAD 2023-01-24 07:22:46 +01:00
percpu_freelist.c bpf: Initialize same number of free nodes for each pcpu_freelist 2022-11-26 09:24:38 +01:00
percpu_freelist.h
prog_iter.c
queue_stack_maps.c
reuseport_array.c
ringbuf.c bpf: Add MEM_RDONLY for helper args that are pointers to rdonly mem. 2022-05-01 17:22:26 +02:00
stackmap.c bpf: Fix excessive memory allocation in stack_map_alloc() 2022-06-06 08:43:42 +02:00
syscall.c bpf: restore the ebpf program ID for BPF_AUDIT_UNLOAD and PERF_BPF_EVENT_PROG_UNLOAD 2023-01-24 07:22:46 +01:00
sysfs_btf.c
task_iter.c bpf: Consolidate task_struct BTF_ID declarations 2021-08-25 10:37:05 -07:00
tnum.c
trampoline.c bpf: Fix potential array overflow in bpf_trampoline_get_progs() 2022-06-06 08:43:42 +02:00
verifier.c bpf: Remove misleading spec_v1 check on var-offset stack read 2023-05-11 23:00:26 +09:00