io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-next] io_uring: fix types in io_recvmsg_multishot_overflow
@ 2022-07-15 13:02 Dylan Yudaken
  2022-07-15 13:33 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Dylan Yudaken @ 2022-07-15 13:02 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov, io-uring; +Cc: Kernel-team, sfr, Dylan Yudaken

io_recvmsg_multishot_overflow had incorrect types on non x64 system.
But also it had an unnecessary INT_MAX check, which could just be done
by changing the type of the accumulator to int (also simplifying the
casts).

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Fixes: a8b38c4ce724 ("io_uring: support multishot in recvmsg")
Signed-off-by: Dylan Yudaken <dylany@fb.com>
---
 io_uring/net.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/io_uring/net.c b/io_uring/net.c
index 616d5f04cc74..6b7d5f33e642 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -327,14 +327,14 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
 
 static bool io_recvmsg_multishot_overflow(struct io_async_msghdr *iomsg)
 {
-	unsigned long hdr;
+	int hdr;
 
-	if (check_add_overflow(sizeof(struct io_uring_recvmsg_out),
-			       (unsigned long)iomsg->namelen, &hdr))
+	if (iomsg->namelen < 0)
 		return true;
-	if (check_add_overflow(hdr, iomsg->controllen, &hdr))
+	if (check_add_overflow((int)sizeof(struct io_uring_recvmsg_out),
+			       iomsg->namelen, &hdr))
 		return true;
-	if (hdr > INT_MAX)
+	if (check_add_overflow(hdr, (int)iomsg->controllen, &hdr))
 		return true;
 
 	return false;

base-commit: a8b38c4ce7240d869c820d457bcd51e452149510
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH for-next] io_uring: fix types in io_recvmsg_multishot_overflow
  2022-07-15 13:02 [PATCH for-next] io_uring: fix types in io_recvmsg_multishot_overflow Dylan Yudaken
@ 2022-07-15 13:33 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2022-07-15 13:33 UTC (permalink / raw)
  To: asml.silence, io-uring, dylany; +Cc: sfr, Kernel-team

On Fri, 15 Jul 2022 06:02:52 -0700, Dylan Yudaken wrote:
> io_recvmsg_multishot_overflow had incorrect types on non x64 system.
> But also it had an unnecessary INT_MAX check, which could just be done
> by changing the type of the accumulator to int (also simplifying the
> casts).
> 
> 

Applied, thanks!

[1/1] io_uring: fix types in io_recvmsg_multishot_overflow
      commit: 184d0a67566383f4f9e85101e4af495abe86f215

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-15 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-15 13:02 [PATCH for-next] io_uring: fix types in io_recvmsg_multishot_overflow Dylan Yudaken
2022-07-15 13:33 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).