linux/include
Pu Lehui 93d1964773 bpf: Fix invalid prog->stats access when update_effective_progs fails
[ Upstream commit 7dc211c115 ]

Syzkaller triggers an invalid memory access issue following fault
injection in update_effective_progs. The issue can be described as
follows:

__cgroup_bpf_detach
  update_effective_progs
    compute_effective_progs
      bpf_prog_array_alloc <-- fault inject
  purge_effective_progs
    /* change to dummy_bpf_prog */
    array->items[index] = &dummy_bpf_prog.prog

---softirq start---
__do_softirq
  ...
    __cgroup_bpf_run_filter_skb
      __bpf_prog_run_save_cb
        bpf_prog_run
          stats = this_cpu_ptr(prog->stats)
          /* invalid memory access */
          flags = u64_stats_update_begin_irqsave(&stats->syncp)
---softirq end---

  static_branch_dec(&cgroup_bpf_enabled_key[atype])

The reason is that fault injection caused update_effective_progs to fail
and then changed the original prog into dummy_bpf_prog.prog in
purge_effective_progs. Then a softirq came, and accessing the members of
dummy_bpf_prog.prog in the softirq triggers invalid mem access.

To fix it, skip updating stats when stats is NULL.

Fixes: 492ecee892 ("bpf: enable program stats")
Signed-off-by: Pu Lehui <pulehui@huawei.com>
Link: https://lore.kernel.org/r/20251115102343.2200727-1-pulehui@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-01-11 15:18:26 +01:00
..
acpi mailbox: pcc: Check before sending MCTP PCC response ACK 2025-12-07 06:12:42 +09:00
asm-generic asm-generic/io.h: Skip trace helpers if rwmmio events are disabled 2025-10-19 16:23:22 +02:00
clocksource x86/hyperv: Fix hv tsc page based sched_clock for hibernation 2025-01-09 13:29:56 +01:00
crypto crypto: sha256 - fix crash at kexec 2025-10-15 11:56:20 +02:00
drm drm/gem: Fix race in drm_gem_handle_create_tail() 2025-07-17 18:32:08 +02:00
dt-bindings ASoC: qcom: q6dsp: add support to more display ports 2025-05-02 07:46:53 +02:00
keys certs: Move load_certificate_list() to be with the asymmetric keys code 2022-06-21 16:05:06 +01:00
kunit kunit: add macro to allow conditionally exposing static symbols to tests 2023-11-20 11:52:08 +01:00
kvm KVM: arm64: Fix host-programmed guest events in nVHE 2024-04-10 16:28:23 +02:00
linux bpf: Fix invalid prog->stats access when update_effective_progs fails 2026-01-11 15:18:26 +01:00
math-emu powerpc/math-emu: Remove -w build flag and fix warnings 2022-09-05 17:28:25 +10:00
media media: v4l2-subdev: Fix alloc failure check in v4l2_subdev_call_state_try() 2025-10-19 16:23:05 +02:00
memory memory: renesas-rpc-if: Remove Runtime PM wrappers 2024-12-14 19:53:37 +01:00
misc ocxl: Update the Process Element Entry 2020-12-04 01:01:30 +11:00
net inet: Avoid ehash lookup race in inet_ehash_insert() 2026-01-11 15:18:19 +01:00
pcmcia ARM: pxa/sa1100: move I/O space to PCI_IOBASE 2022-05-07 22:56:17 +02:00
ras mm, hwpoison: enable memory error handling on 1GB hugepage 2022-08-08 18:06:44 -07:00
rdma RDMA/uverbs: Propagate errors from rdma_lookup_get_uobject() 2025-06-04 14:40:06 +02:00
rv rv: Reset per-task monitors also for idle tasks 2025-02-21 13:49:47 +01:00
scsi scsi: libsas: Add sas_task_find_rq() 2025-10-19 16:23:07 +02:00
soc net: mscc: ocelot: treat 802.1ad tagged traffic as 802.1Q-untagged 2025-05-09 09:41:39 +02:00
sound ASoC: soc-dai.h: merge DAI call back functions into ops 2025-08-28 16:26:03 +02:00
target scsi: target: Fix multiple LUN_RESET handling 2023-05-11 23:03:19 +09:00
trace softirq: Add trace points for tasklet entry/exit 2025-12-07 06:12:34 +09:00
uapi asm-generic: Unify uapi bitsperlong.h for arm64, riscv and loongarch 2025-12-07 06:12:34 +09:00
ufs scsi: ufs: core: Add a quirk to suppress link_startup_again 2025-12-07 06:12:36 +09:00
vdso time64.h: Consolidated PSEC_PER_SEC definition 2021-04-06 16:32:17 -07:00
video video: Provide constants for VGA I/O range 2022-07-19 13:19:11 +02:00
xen xen/mcelog: Add __nonstring annotations for unterminated strings 2025-04-25 10:43:27 +02:00