From: Palash Oswal Date: Tue, 27 Apr 2021 12:51:49 +0000 (+0530) Subject: io_uring: Check current->io_uring in io_uring_cancel_sqpoll X-Git-Tag: v5.15~1256^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d042ffb598ed83e7d5623cc961d249def5b9829;p=platform%2Fkernel%2Flinux-starfive.git io_uring: Check current->io_uring in io_uring_cancel_sqpoll syzkaller identified KASAN: null-ptr-deref Write in io_uring_cancel_sqpoll. io_uring_cancel_sqpoll is called by io_sq_thread before calling io_uring_alloc_task_context. This leads to current->io_uring being NULL. io_uring_cancel_sqpoll should not have to deal with threads where current->io_uring is NULL. In order to cast a wider safety net, perform input sanitisation directly in io_uring_cancel_sqpoll and return for NULL value of current->io_uring. This is safe since if current->io_uring isn't set, then there's no way for the task to have submitted any requests. Reported-by: syzbot+be51ca5a4d97f017cd50@syzkaller.appspotmail.com Cc: stable@vger.kernel.org Signed-off-by: Palash Oswal Link: https://lore.kernel.org/r/20210427125148.21816-1-hello@oswalpalash.com Signed-off-by: Jens Axboe --- diff --git a/fs/io_uring.c b/fs/io_uring.c index 863420e..81096f3 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -9044,6 +9044,8 @@ static void io_uring_cancel_sqpoll(struct io_sq_data *sqd) s64 inflight; DEFINE_WAIT(wait); + if (!current->io_uring) + return; WARN_ON_ONCE(!sqd || sqd->thread != current); atomic_inc(&tctx->in_idle);