Skip to content

Commit d876836

Browse files
committed
io_uring: fix 32-bit compatability with sendmsg/recvmsg
We must set MSG_CMSG_COMPAT if we're in compatability mode, otherwise the iovec import for these commands will not do the right thing and fail the command with -EINVAL. Found by running the test suite compiled as 32-bit. Cc: [email protected] Fixes: aa1fa28 ("io_uring: add support for recvmsg()") Fixes: 0fa03c6 ("io_uring: add support for sendmsg()") Signed-off-by: Jens Axboe <[email protected]>
1 parent bebdb65 commit d876836

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

fs/io_uring.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,6 +3001,11 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
30013001
sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr));
30023002
sr->len = READ_ONCE(sqe->len);
30033003

3004+
#ifdef CONFIG_COMPAT
3005+
if (req->ctx->compat)
3006+
sr->msg_flags |= MSG_CMSG_COMPAT;
3007+
#endif
3008+
30043009
if (!io || req->opcode == IORING_OP_SEND)
30053010
return 0;
30063011
/* iovec is already imported */
@@ -3153,6 +3158,11 @@ static int io_recvmsg_prep(struct io_kiocb *req,
31533158
sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr));
31543159
sr->len = READ_ONCE(sqe->len);
31553160

3161+
#ifdef CONFIG_COMPAT
3162+
if (req->ctx->compat)
3163+
sr->msg_flags |= MSG_CMSG_COMPAT;
3164+
#endif
3165+
31563166
if (!io || req->opcode == IORING_OP_RECV)
31573167
return 0;
31583168
/* iovec is already imported */

0 commit comments

Comments
 (0)