Commit 4e907763 authored by Noorain Eqbal's avatar Noorain Eqbal Committed by Alexei Starovoitov
Browse files

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: 457f4436 ("bpf: Implement BPF ring buffer and verifier support for it")
Reported-by: default avatar <syzbot+2617fc732430968b45d2@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=2617fc732430968b45d2


Tested-by: default avatar <syzbot+2617fc732430968b45d2@syzkaller.appspotmail.com>
Signed-off-by: default avatarNoorain Eqbal <nooraineqbal@gmail.com>
Link: https://lore.kernel.org/r/20251020180301.103366-1-nooraineqbal@gmail.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 6548d364
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment