Skip to contentSkip to conversation

Check reserved flags for send/recv

PATCH New Jens Axboe 1 participant 3 messages Apr 27, 2022

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

cover Check reserved flags for send/recv

Hi,

For some reason we don't check reserved fields for send/sendmsg and recv/recvmsg. We don't use them either, but we should check and -EINVAL if they are set.

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

PATCH 1/2 io_uring: check reserved fields for send/sendmsg

We should check unused fields for non-zero and -EINVAL if they are set, making it consistent with other opcodes.

Fixes 0fa03c624d8f ("io_uring: add support for sendmsg()")
---
 fs/io_uring.c | 2 ++
 1 file changed, 2 insertions(+)
fs/io_uring.c +2 -0
index 1e7466079af7..072fe4e9985f 100644
@@ -5300,6 +5300,8 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 
 	if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
 		return -EINVAL;
+	if (unlikely(sqe->addr2 || sqe->file_index))
+		return -EINVAL;
 
 	sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
 	sr->len = READ_ONCE(sqe->len);
Signature · 1 line
2.35.1
author maintainer
#2 lore raw

PATCH 2/2 io_uring: check reserved fields for recv/recvmsg

In reply to Jens Axboe

We should check unused fields for non-zero and -EINVAL if they are set, making it consistent with other opcodes.

Fixes aa1fa28fc73e ("io_uring: add support for recvmsg()")
---
 fs/io_uring.c | 2 ++
 1 file changed, 2 insertions(+)
fs/io_uring.c +2 -0
index 072fe4e9985f..f1a9595ba4c2 100644
@@ -5535,6 +5535,8 @@ static int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 
 	if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
 		return -EINVAL;
+	if (unlikely(sqe->addr2 || sqe->file_index))
+		return -EINVAL;
 
 	sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
 	sr->len = READ_ONCE(sqe->len);
Signature · 1 line
2.35.1