]> git.ipfire.org Git - thirdparty/linux.git/commit
bpf: Sync pending IRQ work before freeing ring buffer
authorNoorain Eqbal <nooraineqbal@gmail.com>
Mon, 20 Oct 2025 18:03:01 +0000 (23:33 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 21 Oct 2025 16:57:48 +0000 (09:57 -0700)
commit4e9077638301816a7d73fa1e1b4c1db4a7e3b59c
treee2b039af8ceee0b2ef1ebe7e4145d121bcc63484
parent6548d364a3e850326831799d7e3ea2d7bb97ba08
bpf: Sync pending IRQ work before freeing ring buffer

Fix a race where irq_work can be queued in bpf_ringbuf_commit()
but the ring buffer is freed before the work executes.
In the syzbot reproducer, a BPF program attached to sched_switch
triggers bpf_ringbuf_commit(), queuing an irq_work. If the ring buffer
is freed before this work executes, the irq_work thread may accesses
freed memory.
Calling `irq_work_sync(&rb->work)` ensures that all pending irq_work
complete before freeing the buffer.

Fixes: 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support for it")
Reported-by: syzbot+2617fc732430968b45d2@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2617fc732430968b45d2
Tested-by: syzbot+2617fc732430968b45d2@syzkaller.appspotmail.com
Signed-off-by: Noorain Eqbal <nooraineqbal@gmail.com>
Link: https://lore.kernel.org/r/20251020180301.103366-1-nooraineqbal@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/ringbuf.c