From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org
Subject: [PATCH 5.8] io_uring: fix missing ->mm on exit
Date: Mon, 24 Aug 2020 23:35:36 +0300 [thread overview]
Message-ID: <25db35fc25aa7111f67a6747b1281c5151432f8f.1598300802.git.asml.silence@gmail.com> (raw)
do_exit() first drops current->mm and then runs task_work, from where
io_sq_thread_acquire_mm() would try to set mm for a user dying process.
[ 208.004249] WARNING: CPU: 2 PID: 1854 at
kernel/kthread.c:1238 kthread_use_mm+0x244/0x270
[ 208.004287] kthread_use_mm+0x244/0x270
[ 208.004288] io_sq_thread_acquire_mm.part.0+0x54/0x80
[ 208.004290] io_async_task_func+0x258/0x2ac
[ 208.004291] task_work_run+0xc8/0x210
[ 208.004294] do_exit+0x1b8/0x430
[ 208.004295] do_group_exit+0x44/0xac
[ 208.004296] get_signal+0x164/0x69c
[ 208.004298] do_signal+0x94/0x1d0
[ 208.004299] do_notify_resume+0x18c/0x340
[ 208.004300] work_pending+0x8/0x3d4
Reported-by: Roman Gershman <>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
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 493e5047e67c..a8b3a608c553 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -4313,7 +4313,8 @@ static int io_sq_thread_acquire_mm(struct io_ring_ctx *ctx,
struct io_kiocb *req)
{
if (io_op_defs[req->opcode].needs_mm && !current->mm) {
- if (unlikely(!mmget_not_zero(ctx->sqo_mm)))
+ if (unlikely(!(ctx->flags & IORING_SETUP_SQPOLL) ||
+ !mmget_not_zero(ctx->sqo_mm)))
return -EFAULT;
kthread_use_mm(ctx->sqo_mm);
}
--
2.24.0
next reply other threads:[~2020-08-24 20:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 20:35 Pavel Begunkov [this message]
2020-08-24 20:40 ` [PATCH 5.8] io_uring: fix missing ->mm on exit Pavel Begunkov
2020-08-24 20:44 ` 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=25db35fc25aa7111f67a6747b1281c5151432f8f.1598300802.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.