Skip to content

Commit

Permalink
io_uring/net: use proper value for msg_inq
Browse files Browse the repository at this point in the history
struct msghdr->msg_inq is a signed type, yet we attempt to store what
is essentially an unsigned bitmask in there. We only really need to know
if the field was stored or not, but let's use the proper type to avoid
any misunderstandings on what is being attempted here.

Link: https://lore.kernel.org/io-uring/CAHk-=wjKb24aSe6fE4zDH-eh8hr-FB9BbukObUVSMGOrsBHCRQ@mail.gmail.com/
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jens Axboe committed Jun 27, 2023
1 parent 1ef6663 commit b65db92
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions io_uring/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ static inline bool io_recv_finish(struct io_kiocb *req, int *ret,
unsigned int cflags;

cflags = io_put_kbuf(req, issue_flags);
if (msg->msg_inq && msg->msg_inq != -1U)
if (msg->msg_inq && msg->msg_inq != -1)
cflags |= IORING_CQE_F_SOCK_NONEMPTY;

if (!(req->flags & REQ_F_APOLL_MULTISHOT)) {
Expand All @@ -645,7 +645,7 @@ static inline bool io_recv_finish(struct io_kiocb *req, int *ret,
io_recv_prep_retry(req);
/* Known not-empty or unknown state, retry */
if (cflags & IORING_CQE_F_SOCK_NONEMPTY ||
msg->msg_inq == -1U)
msg->msg_inq == -1)
return false;
if (issue_flags & IO_URING_F_MULTISHOT)
*ret = IOU_ISSUE_SKIP_COMPLETE;
Expand Down Expand Up @@ -804,7 +804,7 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
flags |= MSG_DONTWAIT;

kmsg->msg.msg_get_inq = 1;
kmsg->msg.msg_inq = -1U;
kmsg->msg.msg_inq = -1;
if (req->flags & REQ_F_APOLL_MULTISHOT) {
ret = io_recvmsg_multishot(sock, sr, kmsg, flags,
&mshot_finished);
Expand Down Expand Up @@ -902,7 +902,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
if (unlikely(ret))
goto out_free;

msg.msg_inq = -1U;
msg.msg_inq = -1;
msg.msg_flags = 0;

flags = sr->msg_flags;
Expand Down

0 comments on commit b65db92

Please sign in to comment.