If current->mm is not set in SQPOLL mode, then use ctx->sqo_mm; otherwise fail thre request. Signed-off-by: Bijan Mottahedeh <bijan.mottahedeh@xxxxxxxxxx> --- fs/io_uring.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index cb696ab..fd53ea6 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1062,8 +1062,18 @@ static inline void io_req_work_grab_env(struct io_kiocb *req, const struct io_op_def *def) { if (!req->work.mm && def->needs_mm) { - mmgrab(current->mm); - req->work.mm = current->mm; + struct mm_struct *mm = current->mm; + + if (!mm) { + if (req->ctx && req->ctx->sqo_thread) + mm = req->ctx->sqo_mm; + else + req->work.flags |= IO_WQ_WORK_CANCEL; + } + if (mm) { + mmgrab(mm); + req->work.mm = mm; + } } if (!req->work.creds) req->work.creds = get_current_cred(); -- 1.8.3.1