2022-07-15 04:23:10

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: build warning after merge of the block tree

Hi all,

After merging the block tree, today's linux-next build (arm
multi_v7_defconfig) produced this warning:

In file included from include/linux/slab.h:16,
from io_uring/net.c:5:
io_uring/net.c: In function 'io_recvmsg_multishot_overflow':
include/linux/overflow.h:67:22: warning: comparison of distinct pointer types lacks a cast
67 | (void) (&__a == &__b); \
| ^~
io_uring/net.c:332:13: note: in expansion of macro 'check_add_overflow'
332 | if (check_add_overflow(sizeof(struct io_uring_recvmsg_out),
| ^~~~~~~~~~~~~~~~~~
include/linux/overflow.h:68:22: warning: comparison of distinct pointer types lacks a cast
68 | (void) (&__a == __d); \
| ^~
io_uring/net.c:332:13: note: in expansion of macro 'check_add_overflow'
332 | if (check_add_overflow(sizeof(struct io_uring_recvmsg_out),
| ^~~~~~~~~~~~~~~~~~
include/linux/overflow.h:67:22: warning: comparison of distinct pointer types lacks a cast
67 | (void) (&__a == &__b); \
| ^~
io_uring/net.c:335:13: note: in expansion of macro 'check_add_overflow'
335 | if (check_add_overflow(hdr, iomsg->controllen, &hdr))
| ^~~~~~~~~~~~~~~~~~

Introduced by commit

a8b38c4ce724 ("io_uring: support multishot in recvmsg")

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2022-07-15 12:50:22

by Stephen Rothwell

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the block tree

Hi all,

On Fri, 15 Jul 2022 13:52:32 +1000 Stephen Rothwell <[email protected]> wrote:
>
> After merging the block tree, today's linux-next build (arm
> multi_v7_defconfig) produced this warning:
>
> In file included from include/linux/slab.h:16,
> from io_uring/net.c:5:
> io_uring/net.c: In function 'io_recvmsg_multishot_overflow':
> include/linux/overflow.h:67:22: warning: comparison of distinct pointer types lacks a cast
> 67 | (void) (&__a == &__b); \
> | ^~
> io_uring/net.c:332:13: note: in expansion of macro 'check_add_overflow'
> 332 | if (check_add_overflow(sizeof(struct io_uring_recvmsg_out),
> | ^~~~~~~~~~~~~~~~~~
> include/linux/overflow.h:68:22: warning: comparison of distinct pointer types lacks a cast
> 68 | (void) (&__a == __d); \
> | ^~
> io_uring/net.c:332:13: note: in expansion of macro 'check_add_overflow'
> 332 | if (check_add_overflow(sizeof(struct io_uring_recvmsg_out),
> | ^~~~~~~~~~~~~~~~~~
> include/linux/overflow.h:67:22: warning: comparison of distinct pointer types lacks a cast
> 67 | (void) (&__a == &__b); \
> | ^~
> io_uring/net.c:335:13: note: in expansion of macro 'check_add_overflow'
> 335 | if (check_add_overflow(hdr, iomsg->controllen, &hdr))
> | ^~~~~~~~~~~~~~~~~~
>
> Introduced by commit
>
> a8b38c4ce724 ("io_uring: support multishot in recvmsg")

This became a build failure in my i386 defconfig build. So I have
applied the following (probably not correct) patch that makes it build.

From: Stephen Rothwell <[email protected]>
Date: Fri, 15 Jul 2022 21:55:32 +1000
Subject: [PATCH] fix up for "io_uring: support multishot in recvmsg"

Signed-off-by: Stephen Rothwell <[email protected]>
---
io_uring/net.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/io_uring/net.c b/io_uring/net.c
index 616d5f04cc74..187822e18dd6 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -329,10 +329,10 @@ static bool io_recvmsg_multishot_overflow(struct io_async_msghdr *iomsg)
{
unsigned long hdr;

- if (check_add_overflow(sizeof(struct io_uring_recvmsg_out),
+ if (check_add_overflow((unsigned long)sizeof(struct io_uring_recvmsg_out),
(unsigned long)iomsg->namelen, &hdr))
return true;
- if (check_add_overflow(hdr, iomsg->controllen, &hdr))
+ if (check_add_overflow(hdr, (unsigned long)iomsg->controllen, &hdr))
return true;
if (hdr > INT_MAX)
return true;
--
2.35.1

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2022-07-15 13:28:10

by Dylan Yudaken

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the block tree

On Fri, 2022-07-15 at 22:33 +1000, Stephen Rothwell wrote:
> Hi all,
>
> On Fri, 15 Jul 2022 13:52:32 +1000 Stephen Rothwell
> <[email protected]> wrote:
> >
> > After merging the block tree, today's linux-next build (arm
> > multi_v7_defconfig) produced this warning:
> >
> > In file included from include/linux/slab.h:16,
> >                  from io_uring/net.c:5:
> > io_uring/net.c: In function 'io_recvmsg_multishot_overflow':
> > include/linux/overflow.h:67:22: warning: comparison of distinct
> > pointer types lacks a cast
> >    67 |         (void) (&__a == &__b);                  \
> >       |                      ^~
> > io_uring/net.c:332:13: note: in expansion of macro
> > 'check_add_overflow'
> >   332 |         if (check_add_overflow(sizeof(struct
> > io_uring_recvmsg_out),
> >       |             ^~~~~~~~~~~~~~~~~~
> > include/linux/overflow.h:68:22: warning: comparison of distinct
> > pointer types lacks a cast
> >    68 |         (void) (&__a == __d);                   \
> >       |                      ^~
> > io_uring/net.c:332:13: note: in expansion of macro
> > 'check_add_overflow'
> >   332 |         if (check_add_overflow(sizeof(struct
> > io_uring_recvmsg_out),
> >       |             ^~~~~~~~~~~~~~~~~~
> > include/linux/overflow.h:67:22: warning: comparison of distinct
> > pointer types lacks a cast
> >    67 |         (void) (&__a == &__b);                  \
> >       |                      ^~
> > io_uring/net.c:335:13: note: in expansion of macro
> > 'check_add_overflow'
> >   335 |         if (check_add_overflow(hdr, iomsg->controllen,
> > &hdr))
> >       |             ^~~~~~~~~~~~~~~~~~
> >
> > Introduced by commit
> >
> >   a8b38c4ce724 ("io_uring: support multishot in recvmsg")
>
> This became a build failure in my i386 defconfig build.  So I have
> applied the following (probably not correct) patch that makes it
> build.
>

Thanks for this. Your patch will probably not cause much damage,
however I have suggested the below patch to io_uring since I noticed
that the current logic was a bit off

Dylan


From: Dylan Yudaken <[email protected]>
Date: Fri, 15 Jul 2022 05:55:02 -0700
Subject: [PATCH for-next] io_uring: fix types in
io_recvmsg_multishot_overflow

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 <[email protected]>
Fixes: a8b38c4ce724 ("io_uring: support multishot in recvmsg")
Signed-off-by: Dylan Yudaken <[email protected]>
---
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