public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: stable@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>,
	syzbot+ab412638aeb652ded540@syzkaller.appspotmail.com
Subject: [PATCH stable 05/11] io_uring: fix null-deref in io_disable_sqo_submit
Date: Tue, 26 Jan 2021 11:17:04 +0000	[thread overview]
Message-ID: <cdec1207337932aaa7433a4abfd5f38fa4cb2de0.1611659564.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1611659564.git.asml.silence@gmail.com>

[ Upstream commit b4411616c26f26c4017b8fa4d3538b1a02028733 ]

general protection fault, probably for non-canonical address
	0xdffffc0000000022: 0000 [#1] KASAN: null-ptr-deref
	in range [0x0000000000000110-0x0000000000000117]
RIP: 0010:io_ring_set_wakeup_flag fs/io_uring.c:6929 [inline]
RIP: 0010:io_disable_sqo_submit+0xdb/0x130 fs/io_uring.c:8891
Call Trace:
 io_uring_create fs/io_uring.c:9711 [inline]
 io_uring_setup+0x12b1/0x38e0 fs/io_uring.c:9739
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

io_disable_sqo_submit() might be called before user rings were
allocated, don't do io_ring_set_wakeup_flag() in those cases.

Cc: stable@vger.kernel.org # 5.5+
Reported-by: syzbot+ab412638aeb652ded540@syzkaller.appspotmail.com
Fixes: d9d05217cb69 ("io_uring: stop SQPOLL submit on creator's death")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/io_uring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 723e1eb5349a..f1f1de815755 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8726,7 +8726,8 @@ static void io_disable_sqo_submit(struct io_ring_ctx *ctx)
 	mutex_unlock(&ctx->uring_lock);
 
 	/* make sure callers enter the ring to get error */
-	io_ring_set_wakeup_flag(ctx);
+	if (ctx->rings)
+		io_ring_set_wakeup_flag(ctx);
 }
 
 /*
-- 
2.24.0


  parent reply	other threads:[~2021-01-26 12:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 11:16 [PATCH stable 00/11] io_uring for-stable Pavel Begunkov
2021-01-26 11:17 ` [PATCH stable 01/11] kernel/io_uring: cancel io_uring before task works Pavel Begunkov
2021-01-26 11:17 ` [PATCH stable 02/11] io_uring: inline io_uring_attempt_task_drop() Pavel Begunkov
2021-01-26 11:17 ` [PATCH stable 03/11] io_uring: add warn_once for io_uring_flush() Pavel Begunkov
2021-01-26 11:17 ` [PATCH stable 04/11] io_uring: stop SQPOLL submit on creator's death Pavel Begunkov
2021-01-26 11:17 ` Pavel Begunkov [this message]
2021-01-26 11:17 ` [PATCH stable 06/11] io_uring: do sqo disable on install_fd error Pavel Begunkov
2021-01-26 11:17 ` [PATCH stable 07/11] io_uring: fix false positive sqo warning on flush Pavel Begunkov
2021-01-26 11:17 ` [PATCH stable 08/11] io_uring: fix uring_flush in exit_files() warning Pavel Begunkov
2021-01-26 11:17 ` [PATCH stable 09/11] io_uring: fix skipping disabling sqo on exec Pavel Begunkov
2021-01-26 11:17 ` [PATCH stable 10/11] io_uring: dont kill fasync under completion_lock Pavel Begunkov
2021-01-26 11:17 ` [PATCH stable 11/11] io_uring: fix sleeping under spin in __io_clean_op Pavel Begunkov
2021-01-26 17:13 ` [PATCH stable 00/11] io_uring for-stable Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cdec1207337932aaa7433a4abfd5f38fa4cb2de0.1611659564.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+ab412638aeb652ded540@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox