linux/kernel
Anton Protopopov b0b1a8583d bpf: Add a map/btf from a fd array more consistently
The add_fd_from_fd_array() function takes a file descriptor as a
parameter and tries to add either map or btf to the corresponding
list of used objects. As was reported by Dan Carpenter, since the
commit c81e4322acf0 ("bpf: Fix a potential use-after-free of BTF
object"), the fdget() is called twice on the file descriptor, and
thus userspace, potentially, can replace the file pointed to by the
file descriptor in between the two calls. On practice, this shouldn't
break anything on the kernel side, but for consistency fix the code
such that only one fdget() is executed.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/aY689z7gHNv8rgVO@stanley.mountain/
Fixes: ccd2d799ed ("bpf: Fix a potential use-after-free of BTF object")
Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
Link: https://lore.kernel.org/r/20260213212949.759321-1-a.s.protopopov@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2026-02-13 14:37:02 -08:00
..
bpf bpf: Add a map/btf from a fd array more consistently 2026-02-13 14:37:02 -08:00
cgroup mm.git review status for linus..mm-stable 2026-02-12 11:32:37 -08:00
configs
debug
dma virtio,vhost,vdpa: features, fixes 2026-02-13 12:02:18 -08:00
entry
events Performance events changes for v7.0: 2026-02-10 12:00:46 -08:00
futex
gcov
irq pci-v7.0-changes 2026-02-11 17:20:38 -08:00
kcsan mm.git review status for linus..mm-nonmm-stable 2026-02-12 12:13:01 -08:00
livepatch
liveupdate mm.git review status for linus..mm-nonmm-stable 2026-02-12 12:13:01 -08:00
locking
module mm.git review status for linus..mm-nonmm-stable 2026-02-12 12:13:01 -08:00
power mm.git review status for linus..mm-stable 2026-02-12 11:32:37 -08:00
printk Networking changes for 7.0 2026-02-11 19:31:52 -08:00
rcu
sched mm.git review status for linus..mm-nonmm-stable 2026-02-12 12:13:01 -08:00
time Updates for the core time subsystem: 2026-02-10 16:41:59 -08:00
trace runtime verifier changes for 7.0: 2026-02-12 14:08:49 -08:00
unwind
.gitignore
Kconfig.freezer
Kconfig.hz
Kconfig.kexec
Kconfig.locks
Kconfig.preempt
Makefile
acct.c
async.c
audit.c mm.git review status for linus..mm-nonmm-stable 2026-02-12 12:13:01 -08:00
audit.h
audit_fsnotify.c
audit_tree.c
audit_watch.c
auditfilter.c
auditsc.c
backtracetest.c
bounds.c
capability.c
cfi.c
compat.c
configs.c
context_tracking.c
cpu.c
cpu_pm.c
crash_core.c
crash_core_test.c
crash_dump_dm_crypt.c
crash_reserve.c
cred.c
delayacct.c delayacct: fix uapi timespec64 definition 2026-02-08 00:13:32 -08:00
dma.c
elfcorehdr.c
exec_domain.c
exit.c
exit.h
extable.c
fail_function.c
fork.c mm.git review status for linus..mm-nonmm-stable 2026-02-12 12:13:01 -08:00
freezer.c
gen_kheaders.sh
groups.c
hung_task.c
iomem.c
irq_work.c
jump_label.c
kallsyms.c mm.git review status for linus..mm-nonmm-stable 2026-02-12 12:13:01 -08:00
kallsyms_internal.h
kallsyms_selftest.c
kallsyms_selftest.h
kcmp.c
kcov.c
kexec.c
kexec_core.c
kexec_elf.c
kexec_file.c
kexec_internal.h
kheaders.c
kprobes.c
kstack_erase.c
ksyms_common.c
ksysfs.c
kthread.c The kthread code provides an infrastructure which manages the preferred 2026-02-09 19:57:30 -08:00
latencytop.c
module_signature.c
notifier.c
nscommon.c
nsproxy.c
nstree.c
padata.c
panic.c
params.c
pid.c
pid_namespace.c
pid_sysctl.h
profile.c
ptrace.c
range.c
reboot.c
regset.c
relay.c
resource.c cxl changes for v7.0 2026-02-12 16:33:05 -08:00
resource_kunit.c
rseq.c
scftorture.c
scs.c
seccomp.c
signal.c
smp.c
smpboot.c
smpboot.h
softirq.c
stacktrace.c
static_call.c
static_call_inline.c
stop_machine.c
sys.c RISC-V updates for v7.0 2026-02-12 19:17:44 -08:00
sys_ni.c
sysctl-test.c
sysctl.c
task_work.c
taskstats.c
torture.c
tracepoint.c
tsacct.c
ucount.c
uid16.c
uid16.h
umh.c
up.c
user-return-notifier.c
user.c
user_namespace.c
utsname.c
utsname_sysctl.c
vhost_task.c
vmcore_info.c mm.git review status for linus..mm-nonmm-stable 2026-02-12 12:13:01 -08:00
watch_queue.c
watchdog.c watchdog/softlockup: fix sample ring index wrap in need_counting_irqs() 2026-02-08 00:13:34 -08:00
watchdog_buddy.c
watchdog_perf.c watchdog/hardlockup: simplify perf event probe and remove per-cpu dependency 2026-02-08 00:13:35 -08:00
workqueue.c workqueue: Changes for v6.20 2026-02-11 13:13:32 -08:00
workqueue_internal.h