Re: [PATCH] bpf: cgroup: fix null-ptr-deref in __cgroup_bpf_attach

From: bot+bpf-ci

Date: Wed Sep 02 2026 - 05:58:15 EST


> bpf: cgroup: fix null-ptr-deref in __cgroup_bpf_attach
>
> In __cgroup_bpf_attach(), the expression "prog ? : link->link.prog"
> dereferences link before validating that link is non-NULL. If both
> prog and link are NULL (a contract violation by the caller), this
> causes a null pointer dereference.
>
> Add a safe ternary fallback and a NULL check for new_prog before
> it is used further.
>
> Signed-off-by: Liu Jing <liujing@xxxxxxxxxxxxxxxxxxxx>

This looks like a bug fix. Should this include:

Fixes: af6eea57437a ("bpf: Implement bpf_link-based cgroup BPF program attachment")


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/33613365877