linux-stable/kernel/bpf
Stanislav Fomichev 67929e973f bpf: Add BPF_PROG_TYPE_CGROUP_SKB attach type enforcement in BPF_LINK_CREATE
[ Upstream commit 543576ec15 ]

bpf_prog_attach uses attach_type_to_prog_type to enforce proper
attach type for BPF_PROG_TYPE_CGROUP_SKB. link_create uses
bpf_prog_get and relies on bpf_prog_attach_check_attach_type
to properly verify prog_type <> attach_type association.

Add missing attach_type enforcement for the link_create case.
Otherwise, it's currently possible to attach cgroup_skb prog
types to other cgroup hooks.

Fixes: af6eea5743 ("bpf: Implement bpf_link-based cgroup BPF program attachment")
Link: https://lore.kernel.org/bpf/0000000000004792a90615a1dde0@google.com/
Reported-by: syzbot+838346b979830606c854@syzkaller.appspotmail.com
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20240426231621.2716876-2-sdf@google.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-05-30 09:49:19 +02:00
..
preload
Kconfig
Makefile kbuild: make -Woverride-init warnings more consistent 2024-04-10 16:38:00 +02:00
arraymap.c
bloom_filter.c bpf: Check bloom filter map value size 2024-05-17 12:14:39 +02:00
bpf_cgrp_storage.c
bpf_inode_storage.c
bpf_iter.c
bpf_local_storage.c
bpf_lru_list.c
bpf_lru_list.h
bpf_lsm.c
bpf_struct_ops.c
bpf_struct_ops_types.h
bpf_task_storage.c
btf.c bpf: don't emit warnings intended for global subprogs for static subprogs 2024-03-26 18:16:38 -04:00
cgroup.c
cgroup_iter.c
core.c bpf: hardcode BPF_PROG_PACK_SIZE to 2MB * num_possible_nodes() 2024-03-26 18:16:57 -04:00
cpumap.c bpf: report RCU QS in cpumap kthread 2024-03-26 18:17:38 -04:00
cpumask.c
devmap.c bpf: Fix DEVMAP_HASH overflow check on 32-bit arches 2024-03-26 18:16:55 -04:00
disasm.c
disasm.h
dispatcher.c
hashtab.c bpf: Fix hashtab overflow check on 32-bit arches 2024-03-26 18:16:55 -04:00
helpers.c bpf: Mark bpf_spin_{lock,unlock}() helpers with notrace correctly 2024-03-26 18:16:43 -04:00
inode.c bpf: Re-support uid and gid when mounting bpffs 2023-12-21 14:24:30 +01:00
link_iter.c
local_storage.c
log.c
lpm_trie.c
map_in_map.c
map_in_map.h
map_iter.c
memalloc.c bpf: Remove unnecessary cpu == 0 check in memalloc 2024-01-04 10:18:14 -08:00
mmap_unlock_work.h
mprog.c
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 bpf: Fix stackmap overflow check on 32-bit arches 2024-03-26 18:16:55 -04:00
syscall.c bpf: Add BPF_PROG_TYPE_CGROUP_SKB attach type enforcement in BPF_LINK_CREATE 2024-05-30 09:49:19 +02:00
sysfs_btf.c
task_iter.c bpf: Fix an issue due to uninitialized bpf_iter_task 2024-02-19 12:28:15 +01:00
tcx.c
tnum.c
trampoline.c
verifier.c bpf: Fix verifier assumptions about socket->sk 2024-05-30 09:49:17 +02:00