提交 531bd675 编写于 作者: J Jens Axboe 提交者: Joseph Qi

io_uring: io_wq_submit_work() should not touch req->rw

to #26323578

commit fd6c2e4c063d64511657ad0031a1677b6a914859 upstream.

I've been chasing a weird and obscure crash that was userspace stack
corruption, and finally narrowed it down to a bit flip that made a
stack address invalid. io_wq_submit_work() unconditionally flips
the req->rw.ki_flags IOCB_NOWAIT bit, but since it's a generic work
handler, this isn't valid. Normal read/write operations own that
part of the request, on other types it could be something else.

Move the IOCB_NOWAIT clear to the read/write handlers where it belongs.
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 13bd4808
......@@ -1813,6 +1813,10 @@ static int io_read(struct io_kiocb *req, struct io_kiocb **nxt,
return ret;
}
/* Ensure we clear previously set non-block flag */
if (!force_nonblock)
req->rw.ki_flags &= ~IOCB_NOWAIT;
file = req->file;
io_size = ret;
if (req->flags & REQ_F_LINK)
......@@ -1902,6 +1906,10 @@ static int io_write(struct io_kiocb *req, struct io_kiocb **nxt,
return ret;
}
/* Ensure we clear previously set non-block flag */
if (!force_nonblock)
req->rw.ki_flags &= ~IOCB_NOWAIT;
file = kiocb->ki_filp;
io_size = ret;
if (req->flags & REQ_F_LINK)
......@@ -3270,9 +3278,6 @@ static void io_wq_submit_work(struct io_wq_work **workptr)
struct io_kiocb *nxt = NULL;
int ret = 0;
/* Ensure we clear previously set non-block flag */
req->rw.ki_flags &= ~IOCB_NOWAIT;
if (work->flags & IO_WQ_WORK_CANCEL)
ret = -ECANCELED;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册