WSL2-Linux-Kernel/Documentation
David Vernet 6c831c4684 bpf: Treat KF_RELEASE kfuncs as KF_TRUSTED_ARGS
KF_RELEASE kfuncs are not currently treated as having KF_TRUSTED_ARGS,
even though they have a superset of the requirements of KF_TRUSTED_ARGS.
Like KF_TRUSTED_ARGS, KF_RELEASE kfuncs require a 0-offset argument, and
don't allow NULL-able arguments. Unlike KF_TRUSTED_ARGS which require
_either_ an argument with ref_obj_id > 0, _or_ (ref->type &
BPF_REG_TRUSTED_MODIFIERS) (and no unsafe modifiers allowed), KF_RELEASE
only allows for ref_obj_id > 0.  Because KF_RELEASE today doesn't
automatically imply KF_TRUSTED_ARGS, some of these requirements are
enforced in different ways that can make the behavior of the verifier
feel unpredictable. For example, a KF_RELEASE kfunc with a NULL-able
argument will currently fail in the verifier with a message like, "arg#0
is ptr_or_null_ expected ptr_ or socket" rather than "Possibly NULL
pointer passed to trusted arg0". Our intention is the same, but the
semantics are different due to implemenetation details that kfunc authors
and BPF program writers should not need to care about.

Let's make the behavior of the verifier more consistent and intuitive by
having KF_RELEASE kfuncs imply the presence of KF_TRUSTED_ARGS. Our
eventual goal is to have all kfuncs assume KF_TRUSTED_ARGS by default
anyways, so this takes us a step in that direction.

Note that it does not make sense to assume KF_TRUSTED_ARGS for all
KF_ACQUIRE kfuncs. KF_ACQUIRE kfuncs can have looser semantics than
KF_RELEASE, with e.g. KF_RCU | KF_RET_NULL. We may want to have
KF_ACQUIRE imply KF_TRUSTED_ARGS _unless_ KF_RCU is specified, but that
can be left to another patch set, and there are no such subtleties to
address for KF_RELEASE.

Signed-off-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/r/20230325213144.486885-4-void@manifault.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2023-03-25 16:56:22 -07:00
..
ABI ARM: SoC drivers for 6.3 2023-02-27 10:04:49 -08:00
PCI
RCU
accel
accounting
admin-guide media updates for v6.3-rc1 2023-02-26 11:47:26 -08:00
arc
arm
arm64
block
bpf bpf: Treat KF_RELEASE kfuncs as KF_TRUSTED_ARGS 2023-03-25 16:56:22 -07:00
cdrom
core-api
cpu-freq
crypto
dev-tools
devicetree dt-bindings: net: dsa: mediatek,mt7530: change some descriptions to literal 2023-03-08 13:05:37 +00:00
doc-guide
driver-api media updates for v6.3-rc1 2023-02-26 11:47:26 -08:00
fault-injection
fb
features
filesystems
firmware-guide
firmware_class
fpga
gpu
hid
hwmon
i2c
ia64
iio
images
infiniband
input
isdn
kbuild Kbuild updates for v6.3 2023-02-26 11:53:25 -08:00
kernel-hacking
leds
litmus-tests
livepatch
locking
loongarch
m68k
maintainer
mhi
mips
misc-devices
mm
netlabel
netlink
networking Including fixes from wireless and netfilter. 2023-02-27 14:05:08 -08:00
nios2
nvdimm
nvme
openrisc
parisc
pcmcia
peci
power
powerpc
process Documentation: simplify and clarify DCO contribution example language 2023-02-26 11:25:04 -08:00
riscv
rust
s390 VFIO updates for v6.3-rc1 2023-02-25 11:52:57 -08:00
scheduler
scsi
security
sh
sound
sparc
sphinx
sphinx-static
spi
staging
target
timers
tools
trace
translations
usb
userspace-api media updates for v6.3-rc1 2023-02-26 11:47:26 -08:00
virt ARM: 2023-02-25 11:30:21 -08:00
w1
watchdog
x86
xtensa
.gitignore
Changes
CodingStyle
Kconfig
Makefile
SubmittingPatches
arch.rst
atomic_bitops.txt
atomic_t.txt
conf.py
docutils.conf
dontdiff
index.rst
memory-barriers.txt
subsystem-apis.rst