linux/include
Martin KaFai Lau 4a9c7bbe2e bpf: Resolve to prog->aux->dst_prog->type only for BPF_PROG_TYPE_EXT
The commit 7e40781cc8 ("bpf: verifier: Use target program's type for access verifications")
fixes the verifier checking for BPF_PROG_TYPE_EXT (extension)
prog such that the verifier looks for things based
on the target prog type that it is extending instead of
the BPF_PROG_TYPE_EXT itself.

The current resolve_prog_type() returns the target prog type.
It checks for nullness on prog->aux->dst_prog.  However,
when loading a BPF_PROG_TYPE_TRACING prog and it is tracing another
bpf prog instead of a kernel function, prog->aux->dst_prog is not
NULL also.  In this case, the verifier should still verify as the
BPF_PROG_TYPE_TRACING type instead of the traced prog type in
prog->aux->dst_prog->type.

An oops has been reported when tracing a struct_ops prog.  A NULL
dereference happened in check_return_code() when accessing the
prog->aux->attach_func_proto->type and prog->aux->attach_func_proto
is NULL here because the traced struct_ops prog has the "unreliable" set.

This patch is to change the resolve_prog_type() to only
return the target prog type if the prog being verified is
BPF_PROG_TYPE_EXT.

Fixes: 7e40781cc8 ("bpf: verifier: Use target program's type for access verifications")
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20220330011456.2984509-1-kafai@fb.com
2022-03-30 19:31:30 -07:00
..
acpi Merge branches 'acpi-soc', 'acpi-video' and 'acpi-apei' 2022-03-18 17:48:55 +01:00
asm-generic Add support for Intel CET-IBT, available since Tigerlake (11th gen), which is a 2022-03-27 10:17:23 -07:00
clocksource
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2022-03-21 16:02:36 -07:00
drm
dt-bindings Staging driver update for 5.18-rc1 2022-03-28 12:50:50 -07:00
keys KEYS: Introduce link restriction for machine keys 2022-03-08 13:55:52 +02:00
kunit
kvm
linux bpf: Resolve to prog->aux->dst_prog->type only for BPF_PROG_TYPE_EXT 2022-03-30 19:31:30 -07:00
math-emu
media
memory
misc
net Networking changes for 5.18. 2022-03-24 13:13:26 -07:00
pcmcia
ras mm/memory-failure.c: fix race with changing page compound again 2022-03-22 15:57:07 -07:00
rdma
scsi SCSI misc on 20220324 2022-03-24 19:37:53 -07:00
soc drm for 5.18-rc1 2022-03-24 16:19:43 -07:00
sound flexible-array transformations for 5.18-rc1 2022-03-24 11:39:32 -07:00
target scsi: target: Add iscsi/cpus_allowed_list in configfs 2022-03-14 23:40:36 -04:00
trace Char/Misc and other driver updates for 5.18-rc1 2022-03-28 12:27:35 -07:00
uapi TTY/Serial driver changes for 5.18-rc1 2022-03-28 13:00:51 -07:00
vdso
video
xen xen/grant-table: remove readonly parameter from functions 2022-03-15 20:34:40 -05:00