Re: [syzbot] [fs?] KASAN: slab-use-after-free Read in sys_io_cancel
From: Hillf Danton
Date: Mon Mar 04 2024 - 05:45:26 EST
On Sat, 02 Mar 2024 23:29:23 -0800
> syzbot found the following issue on:
>
> HEAD commit: 5ad3cb0ed525 Merge tag 'for-v6.8-rc2' of git://git.kernel...
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13877412180000
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
--- x/fs/aio.c
+++ y/fs/aio.c
@@ -2195,6 +2195,11 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t
if (kiocb->ki_res.obj == obj) {
ret = kiocb->ki_cancel(&kiocb->rw);
list_del_init(&kiocb->ki_list);
+ if (ret == 0 && kiocb->rw.ki_flags & IOCB_AIO_RW) {
+ struct aio_kiocb *iocb = container_of(&kiocb->rw,
+ struct aio_kiocb, rw);
+ refcount_inc(&iocb->ki_refcnt);
+ }
break;
}
}
--