From: Ming Lei Date: Fri, 10 May 2024 03:50:27 +0000 (+0800) Subject: io_uring: fail NOP if non-zero op flags is passed in X-Git-Tag: v5.4.278~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6e23457791aa1cad4bdeab24b517970113f2ed54;p=thirdparty%2Fkernel%2Fstable.git io_uring: fail NOP if non-zero op flags is passed in commit 3d8f874bd620ce03f75a5512847586828ab86544 upstream. The NOP op flags should have been checked from beginning like any other opcode, otherwise NOP may not be extended with the op flags. Given both liburing and Rust io-uring crate always zeros SQE op flags, just ignore users which play raw NOP uring interface without zeroing SQE, because NOP is just for test purpose. Then we can save one NOP2 opcode. Suggested-by: Jens Axboe Fixes: 2b188cc1bb85 ("Add io_uring IO interface") Cc: stable@vger.kernel.org Signed-off-by: Ming Lei Link: https://lore.kernel.org/r/20240510035031.78874-2-ming.lei@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/io_uring.c b/fs/io_uring.c index 2c793e4ccf096..4cfddd7124521 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2112,6 +2112,8 @@ static int __io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req, switch (req->submit.opcode) { case IORING_OP_NOP: + if (READ_ONCE(s->sqe->rw_flags)) + return -EINVAL; ret = io_nop(req, req->user_data); break; case IORING_OP_READV: