#syz test
Fix a possible vmalloc out-of-bounds access caused by pending IRQ work
Reported-by: syzbot+2617fc732430968b45d2@syzkaller.appspotmail.com
Signed-off-by: neqbal <nooraineqbal@gmail.com>
---
kernel/bpf/ringbuf.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/bpf/ringbuf.c b/kernel/bpf/ringbuf.c
index 719d73299397..a6597417412f 100644
--- a/kernel/bpf/ringbuf.c
+++ b/kernel/bpf/ringbuf.c
@@ -216,6 +216,12 @@ static struct bpf_map *ringbuf_map_alloc(union bpf_attr *attr)
static void bpf_ringbuf_free(struct bpf_ringbuf *rb)
{
+ /* Ensure all pending IRQ work completes before freeing.
+ * In PREEMPT_RT, IRQ work runs in thread context and can
+ * race with ring buffer destruction.
+ */
+ irq_work_sync(&rb->work);
+
/* copy pages pointer and nr_pages to local variable, as we are going
* to unmap rb itself with vunmap() below
*/
--
2.51.0