Re: [PATCH] bpf: Fix cgroup link update after a failed effective array rebuild
From: J4f J4f
Date: Wed Nov 18 2026 - 09:42:05 EST
On Fri, 13 Nov 2026 at 03:57, Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> On Thu Nov 12, 2026 at 1:49 PM UTC, Shihuang Liu wrote:
> > replace_effective_prog() uses the position of a cgroup program list
> > entry as a physical index into the effective program array. When an
> > OOM detach falls back to purge_effective_progs(), the detached entry is
> > replaced by a dummy but the other entries keep their position, so the
> > list position no longer matches the array index. A later link update
> > then writes the new program into the wrong slot, leaving the old
> > program pointer in the array. The array does not hold a reference, so
> > the old program can be freed while it is still published.
>
> I doubt you managed to reproduce such scenario.
> So wont-fix until there is one.
>
> pw-bot: cr
I reproduced it on f66469d9905b39 (7.4.0-rc1).
[ 4.307527] BUG: KASAN: vmalloc-out-of-bounds in
cgroup_bpf_prog_query+0xdf1/0x10a0
[ 4.307589] Read of size 8 at addr ffffc90000073050 by task exp/74
[ 4.307593]
[ 4.307597] CPU: 0 UID: 0 PID: 74 Comm: exp Not tainted
7.4.0-rc1-00536-gf66469d9905b #3 PREEMPT(lazy)
[ 4.307602] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX,
arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 4.307605] Call Trace:
[ 4.307610] <TASK>
[ 4.307613] dump_stack_lvl+0x53/0x70
[ 4.307622] print_report+0xd0/0x630
[ 4.307628] ? __pfx__raw_spin_lock_irqsave+0x10/0x10
[ 4.307633] ? cgroup_bpf_prog_query+0xdf1/0x10a0
[ 4.307637] kasan_report+0xce/0x100
[ 4.307641] ? cgroup_bpf_prog_query+0xdf1/0x10a0
[ 4.307645] cgroup_bpf_prog_query+0xdf1/0x10a0