Skip to contentSkip to conversation

Add iopoll/sqe field checks to unlink/rename

PATCH New Jens Axboe 1 participant 3 messages Jun 23, 2021

Subsystems (3)
lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

cover Add iopoll/sqe field checks to unlink/rename

Hi,

For some reason these were missed when added, ensure we get them added now. The IOPOLL is a correctness issue in that we cannot mix and match polled and waitable IO on the same context, the field checking is more of a sanity thing that allows us to more easily extend it in the future, if need be.

Signature · 1 line
Jens Axboe
author maintainer
#1 lore raw

PATCH 1/2 io_uring: add IOPOLL and reserved field checks to IORING_OP_RENAMEAT

We can't support IOPOLL with non-pollable request types, and we should check for unused/reserved fields like we do for other request types.

Fixes 80a261fd0032 ("io_uring: add support for IORING_OP_RENAMEAT")
---
 fs/io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/io_uring.c +4 -0
index fa8794c61af7..9b6c7dad0b73 100644
@@ -3453,6 +3453,10 @@ static int io_renameat_prep(struct io_kiocb *req,
 	struct io_rename *ren = &req->rename;
 	const char __user *oldf, *newf;
 
+	if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
+		return -EINVAL;
+	if (sqe->ioprio || sqe->buf_index)
+		return -EINVAL;
 	if (unlikely(req->flags & REQ_F_FIXED_FILE))
 		return -EBADF;
 
Signature · 1 line
2.32.0
author maintainer
#2 lore raw

PATCH 2/2 io_uring: add IOPOLL and reserved field checks to IORING_OP_UNLINKAT

In reply to Jens Axboe

We can't support IOPOLL with non-pollable request types, and we should check for unused/reserved fields like we do for other request types.

Fixes 14a1143b68ee ("io_uring: add support for IORING_OP_UNLINKAT")
---
 fs/io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/io_uring.c +4 -0
index 9b6c7dad0b73..45c606846303 100644
@@ -3504,6 +3504,10 @@ static int io_unlinkat_prep(struct io_kiocb *req,
 	struct io_unlink *un = &req->unlink;
 	const char __user *fname;
 
+	if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
+		return -EINVAL;
+	if (sqe->ioprio || sqe->off || sqe->len || sqe->buf_index)
+		return -EINVAL;
 	if (unlikely(req->flags & REQ_F_FIXED_FILE))
 		return -EBADF;
 
Signature · 1 line
2.32.0