linux-stable/include
Kumar Kartikeya Dwivedi f8064ab90d bpf: Invalidate slices on destruction of dynptrs on stack
The previous commit implemented destroy_if_dynptr_stack_slot. It
destroys the dynptr which given spi belongs to, but still doesn't
invalidate the slices that belong to such a dynptr. While for the case
of referenced dynptr, we don't allow their overwrite and return an error
early, we still allow it and destroy the dynptr for unreferenced dynptr.

To be able to enable precise and scoped invalidation of dynptr slices in
this case, we must be able to associate the source dynptr of slices that
have been obtained using bpf_dynptr_data. When doing destruction, only
slices belonging to the dynptr being destructed should be invalidated,
and nothing else. Currently, dynptr slices belonging to different
dynptrs are indistinguishible.

Hence, allocate a unique id to each dynptr (CONST_PTR_TO_DYNPTR and
those on stack). This will be stored as part of reg->id. Whenever using
bpf_dynptr_data, transfer this unique dynptr id to the returned
PTR_TO_MEM_OR_NULL slice pointer, and store it in a new per-PTR_TO_MEM
dynptr_id register state member.

Finally, after establishing such a relationship between dynptrs and
their slices, implement precise invalidation logic that only invalidates
slices belong to the destroyed dynptr in destroy_if_dynptr_stack_slot.

Acked-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230121002241.2113993-5-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2023-01-20 17:55:03 -08:00
..
acpi ACPI: video: Allow GPU drivers to report no panels 2022-12-22 17:26:41 +01:00
asm-generic arch: fix broken BuildID for arm64 and riscv 2022-12-30 17:21:51 +09:00
clocksource Updates for timers, timekeeping and drivers: 2022-12-12 12:52:02 -08:00
crypto
drm
dt-bindings remoteproc updates for v6.2 2022-12-21 09:37:14 -08:00
keys
kunit kunit: add macro to allow conditionally exposing static symbols to tests 2022-12-12 14:13:48 -07:00
kvm
linux bpf: Invalidate slices on destruction of dynptrs on stack 2023-01-20 17:55:03 -08:00
math-emu
media
memory
misc
net devlink: remove the registration guarantee of references 2023-01-06 12:56:19 +00:00
pcmcia
ras
rdma
rv
scsi SCSI misc on 20221222 2022-12-22 11:22:31 -08:00
soc Networking changes for 6.2. 2022-12-13 15:47:48 -08:00
sound
target
trace Including fixes from bpf, wifi, and netfilter. 2023-01-05 12:40:50 -08:00
uapi bpf: Add ipip6 and ip6ip decap support for bpf_skb_adjust_room() 2023-01-15 12:56:17 -08:00
ufs
vdso
video fbdev: omapfb: connector-analog-tv: remove support for platform data 2022-12-14 20:01:49 +01:00
xen