linux/include
Ning Ding 7441ee8276 bpf: Reject untrusted allocated-object pointers
When the final RCU read-side critical section ends, a local kptr is demoted
to PTR_UNTRUSTED but retains MEM_ALLOC. The pointer may be NULL or may refer
to an object whose lifetime is no longer protected.

type_is_ptr_alloc_obj() nevertheless recognizes any PTR_TO_BTF_ID with
MEM_ALLOC as a live allocated object. In particular, a refcount-only local
kptr never carries NON_OWN_REF, so it still passes the
bpf_refcount_acquire() argument check after RCU protection ends. The kfunc
can then dereference NULL or stale memory.

Make type_is_ptr_alloc_obj() reject PTR_UNTRUSTED pointers. Since
type_is_non_owning_ref() is based on the same predicate, graph kfunc
arguments obey the same live-object requirement. Fault-protected reads of
the demoted pointer remain valid: writes are already rejected, and read
fixups use bpf_may_fault_on_deref() rather than this predicate.

Fixes: 1b12171533 ("bpf: Mark direct ld of stashed bpf_{rb,list}_node as non-owning ref")
Reported-by: Nicholas Carlini <npc@anthropic.com>
Suggested-by: Nicholas Carlini <npc@anthropic.com>
Signed-off-by: Ning Ding <dingning04@gmail.com>
[ kkd: Rewrote commit log ]
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20260904084325.52250-8-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2026-09-04 07:58:36 -07:00
..
acpi Driver core changes for 7.3-rc1 2026-08-19 10:42:18 -07:00
asm-generic audit/stable-7.3 PR 20260814 2026-08-19 16:21:32 -07:00
clocksource clocksource/drivers/samsung_pwm: Switch to raw_spinlock_t type 2026-08-13 18:13:15 +02:00
crypto This update includes the following changes: 2026-08-19 17:25:42 -07:00
cxl cxl: Support dpa without a mailbox 2026-06-29 10:55:47 -07:00
drm Revert "drm/sched: Remove FIFO and RR and simplify to a single run queue" 2026-08-11 17:34:10 +01:00
dt-bindings sound updates for 7.3-rc1 2026-08-19 10:04:59 -07:00
hyperv mshv: fix hv_input_get_system_property struct 2026-07-22 21:58:21 +00:00
keys
kunit gpio updates for v7.3-rc1 2026-08-19 09:10:07 -07:00
kvm KVM: arm64: vgic: Fix race between LPI release and re-registration 2026-07-23 09:56:57 +01:00
linux bpf: Reject untrusted allocated-object pointers 2026-09-04 07:58:36 -07:00
math-emu
media media: rppx1: Add framework to support Dreamchip RPPX1 ISP 2026-07-30 20:51:35 +03:00
memory
misc
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-08-18 10:42:41 -07:00
pcmcia Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (headers) 2026-07-03 07:38:16 +02:00
ras
rdma
rv rv: Add KUnit tests for some LTL monitors 2026-07-31 16:27:46 +02:00
scsi ata changes for 7.3 2026-08-19 12:31:50 -07:00
soc regulator: Updates for v7.3 2026-08-19 09:36:58 -07:00
sound ASoC: Updates for v7.3 2026-08-18 08:35:39 +02:00
target
trace Networking changes for 7.3. 2026-08-20 08:16:04 -07:00
uapi Networking changes for 7.3. 2026-08-20 08:16:04 -07:00
ufs
vdso vDSO: Make clockmode constants available without CONFIG_GENERIC_GETTIMEOFDAY 2026-08-10 16:25:21 +02:00
video
xen xen: Drop CONFIG_XEN_AUTO_XLATE 2026-08-06 13:18:32 +02:00
Kbuild