* [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare
@ 2024-03-28 14:30 Arnd Bergmann
2024-03-28 14:30 ` [PATCH 7/9] infiniband: uverbs: avoid out-of-range warnings Arnd Bergmann
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Arnd Bergmann @ 2024-03-28 14:30 UTC (permalink / raw)
To: linux-kernel
Cc: Arnd Bergmann, Ilya Dryomov, Dongsheng Yang, Jens Axboe,
Jason Gunthorpe, Leon Romanovsky, Alasdair Kergon, Mike Snitzer,
Mikulas Patocka, dm-devel, Saeed Mahameed, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Xiubo Li, Jeff Layton,
Ryusuke Konishi, Dmitry Vyukov, Andrey Konovalov, David Ahern,
Masahiro Yamada, Nathan Chancellor, Nicolas Schier,
Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook,
Gustavo A. R. Silva, Tariq Toukan, ceph-devel, linux-block,
linux-rdma, netdev, linux-nilfs, kasan-dev, linux-kbuild, llvm
From: Arnd Bergmann <arnd@arndb.de>
The warning option was introduced a few years ago but left disabled
by default. All of the actual bugs that this has found have been
fixed in the meantime, and this series should address the remaining
false-positives, as tested on arm/arm64/x86 randconfigs as well as
allmodconfig builds for all architectures supported by clang.
Please apply the patches individually to subsystem maintainer trees.
Arnd
Arnd Bergmann (9):
dm integrity: fix out-of-range warning
libceph: avoid clang out-of-range warning
rbd: avoid out-of-range warning
kcov: avoid clang out-of-range warning
ipv4: tcp_output: avoid warning about NET_ADD_STATS
nilfs2: fix out-of-range warning
infiniband: uverbs: avoid out-of-range warnings
mlx5: stop warning for 64KB pages
kbuild: enable tautological-constant-out-of-range-compare
drivers/block/rbd.c | 2 +-
drivers/infiniband/core/uverbs_ioctl.c | 4 ++--
drivers/md/dm-integrity.c | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 6 ++++--
fs/ceph/snap.c | 2 +-
fs/nilfs2/ioctl.c | 2 +-
kernel/kcov.c | 3 ++-
net/ceph/osdmap.c | 4 ++--
net/ipv4/tcp_output.c | 2 +-
scripts/Makefile.extrawarn | 1 -
10 files changed, 15 insertions(+), 13 deletions(-)
--
2.39.2
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Dongsheng Yang <dongsheng.yang@easystack.cn>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Alasdair Kergon <agk@redhat.com>
Cc: Mike Snitzer <snitzer@kernel.org>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: dm-devel@lists.linux.dev
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Xiubo Li <xiubli@redhat.com>
Cc: Jeff Layton <jlayton@kernel.org>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: David Ahern <dsahern@kernel.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Tariq Toukan <tariqt@nvidia.com>
Cc: ceph-devel@vger.kernel.org
Cc: linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-rdma@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: linux-nilfs@vger.kernel.org
Cc: kasan-dev@googlegroups.com
Cc: linux-kbuild@vger.kernel.org
Cc: llvm@lists.linux.dev
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH 7/9] infiniband: uverbs: avoid out-of-range warnings 2024-03-28 14:30 [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare Arnd Bergmann @ 2024-03-28 14:30 ` Arnd Bergmann 2024-03-28 22:12 ` Justin Stitt 2024-04-03 15:45 ` Jason Gunthorpe 2024-03-28 14:30 ` [PATCH 8/9] mlx5: stop warning for 64KB pages Arnd Bergmann 2024-03-29 20:00 ` [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare patchwork-bot+netdevbpf 2 siblings, 2 replies; 11+ messages in thread From: Arnd Bergmann @ 2024-03-28 14:30 UTC (permalink / raw) To: linux-kernel, Jason Gunthorpe, Leon Romanovsky, Nathan Chancellor Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook, Gustavo A. R. Silva, linux-rdma, llvm From: Arnd Bergmann <arnd@arndb.de> clang warns for comparisons that are always true, which is the case for these two page size checks on architectures with 64KB pages: drivers/infiniband/core/uverbs_ioctl.c:90:39: error: result of comparison of constant 65536 with expression of type 'u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] WARN_ON_ONCE(method_elm->bundle_size > PAGE_SIZE); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ include/asm-generic/bug.h:104:25: note: expanded from macro 'WARN_ON_ONCE' int __ret_warn_on = !!(condition); \ ^~~~~~~~~ drivers/infiniband/core/uverbs_ioctl.c:621:17: error: result of comparison of constant 65536 with expression of type '__u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (hdr.length > PAGE_SIZE || ~~~~~~~~~~ ^ ~~~~~~~~~ Add a cast to u32 in both cases, so it never warns about this. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/infiniband/core/uverbs_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/uverbs_ioctl.c b/drivers/infiniband/core/uverbs_ioctl.c index f80da6a67e24..e0cc3ddae71b 100644 --- a/drivers/infiniband/core/uverbs_ioctl.c +++ b/drivers/infiniband/core/uverbs_ioctl.c @@ -90,7 +90,7 @@ void uapi_compute_bundle_size(struct uverbs_api_ioctl_method *method_elm, ALIGN(bundle_size + 256, sizeof(*pbundle->internal_buffer)); /* Do not want order-2 allocations for this. */ - WARN_ON_ONCE(method_elm->bundle_size > PAGE_SIZE); + WARN_ON_ONCE((u32)method_elm->bundle_size > PAGE_SIZE); } /** @@ -636,7 +636,7 @@ long ib_uverbs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) if (err) return -EFAULT; - if (hdr.length > PAGE_SIZE || + if ((u32)hdr.length > PAGE_SIZE || hdr.length != struct_size(&hdr, attrs, hdr.num_attrs)) return -EINVAL; -- 2.39.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 7/9] infiniband: uverbs: avoid out-of-range warnings 2024-03-28 14:30 ` [PATCH 7/9] infiniband: uverbs: avoid out-of-range warnings Arnd Bergmann @ 2024-03-28 22:12 ` Justin Stitt 2024-04-03 15:45 ` Jason Gunthorpe 1 sibling, 0 replies; 11+ messages in thread From: Justin Stitt @ 2024-03-28 22:12 UTC (permalink / raw) To: Arnd Bergmann Cc: linux-kernel, Jason Gunthorpe, Leon Romanovsky, Nathan Chancellor, Arnd Bergmann, Nick Desaulniers, Bill Wendling, Kees Cook, Gustavo A. R. Silva, linux-rdma, llvm On Thu, Mar 28, 2024 at 7:32 AM Arnd Bergmann <arnd@kernel.org> wrote: > Add a cast to u32 in both cases, so it never warns about this. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Justin Stitt <justinstitt@google.com> > --- > drivers/infiniband/core/uverbs_ioctl.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/core/uverbs_ioctl.c b/drivers/infiniband/core/uverbs_ioctl.c > index f80da6a67e24..e0cc3ddae71b 100644 > --- a/drivers/infiniband/core/uverbs_ioctl.c > +++ b/drivers/infiniband/core/uverbs_ioctl.c > @@ -90,7 +90,7 @@ void uapi_compute_bundle_size(struct uverbs_api_ioctl_method *method_elm, > ALIGN(bundle_size + 256, sizeof(*pbundle->internal_buffer)); > > /* Do not want order-2 allocations for this. */ > - WARN_ON_ONCE(method_elm->bundle_size > PAGE_SIZE); > + WARN_ON_ONCE((u32)method_elm->bundle_size > PAGE_SIZE); > } > > /** > @@ -636,7 +636,7 @@ long ib_uverbs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > if (err) > return -EFAULT; > > - if (hdr.length > PAGE_SIZE || > + if ((u32)hdr.length > PAGE_SIZE || > hdr.length != struct_size(&hdr, attrs, hdr.num_attrs)) > return -EINVAL; > > -- > 2.39.2 > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 7/9] infiniband: uverbs: avoid out-of-range warnings 2024-03-28 14:30 ` [PATCH 7/9] infiniband: uverbs: avoid out-of-range warnings Arnd Bergmann 2024-03-28 22:12 ` Justin Stitt @ 2024-04-03 15:45 ` Jason Gunthorpe 2024-04-03 20:16 ` Arnd Bergmann 1 sibling, 1 reply; 11+ messages in thread From: Jason Gunthorpe @ 2024-04-03 15:45 UTC (permalink / raw) To: Arnd Bergmann Cc: linux-kernel, Leon Romanovsky, Nathan Chancellor, Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook, Gustavo A. R. Silva, linux-rdma, llvm On Thu, Mar 28, 2024 at 03:30:45PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > clang warns for comparisons that are always true, which is the case > for these two page size checks on architectures with 64KB pages: > > drivers/infiniband/core/uverbs_ioctl.c:90:39: error: result of comparison of constant 65536 with expression of type 'u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] > WARN_ON_ONCE(method_elm->bundle_size > PAGE_SIZE); > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ > include/asm-generic/bug.h:104:25: note: expanded from macro 'WARN_ON_ONCE' > int __ret_warn_on = !!(condition); \ > ^~~~~~~~~ > drivers/infiniband/core/uverbs_ioctl.c:621:17: error: result of comparison of constant 65536 with expression of type '__u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] > if (hdr.length > PAGE_SIZE || > ~~~~~~~~~~ ^ ~~~~~~~~~ > > Add a cast to u32 in both cases, so it never warns about this. But doesn't that hurt the codegen? Jason ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 7/9] infiniband: uverbs: avoid out-of-range warnings 2024-04-03 15:45 ` Jason Gunthorpe @ 2024-04-03 20:16 ` Arnd Bergmann 0 siblings, 0 replies; 11+ messages in thread From: Arnd Bergmann @ 2024-04-03 20:16 UTC (permalink / raw) To: Jason Gunthorpe, Arnd Bergmann Cc: linux-kernel, Leon Romanovsky, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook, Gustavo A. R. Silva, linux-rdma, llvm On Wed, Apr 3, 2024, at 17:45, Jason Gunthorpe wrote: > On Thu, Mar 28, 2024 at 03:30:45PM +0100, Arnd Bergmann wrote: >> From: Arnd Bergmann <arnd@arndb.de> >> >> clang warns for comparisons that are always true, which is the case >> for these two page size checks on architectures with 64KB pages: >> >> drivers/infiniband/core/uverbs_ioctl.c:90:39: error: result of comparison of constant 65536 with expression of type 'u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] >> WARN_ON_ONCE(method_elm->bundle_size > PAGE_SIZE); >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ >> include/asm-generic/bug.h:104:25: note: expanded from macro 'WARN_ON_ONCE' >> int __ret_warn_on = !!(condition); \ >> ^~~~~~~~~ >> drivers/infiniband/core/uverbs_ioctl.c:621:17: error: result of comparison of constant 65536 with expression of type '__u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] >> if (hdr.length > PAGE_SIZE || >> ~~~~~~~~~~ ^ ~~~~~~~~~ >> >> Add a cast to u32 in both cases, so it never warns about this. > > But doesn't that hurt the codegen? I just double-checked in the compiler explorer to confirm that this works as I expected: both gcc and clang are still able to optimize out the comparison for 64K pages, but clang no longer complains after my change that this is an obvious case. I also see that gcc still produces a -Wtype-limits warning, but that likely has to stay disabled because it produces too much output elsewhere and I don't see an easy way to shut it up. Arnd ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 8/9] mlx5: stop warning for 64KB pages 2024-03-28 14:30 [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare Arnd Bergmann 2024-03-28 14:30 ` [PATCH 7/9] infiniband: uverbs: avoid out-of-range warnings Arnd Bergmann @ 2024-03-28 14:30 ` Arnd Bergmann 2024-03-28 15:37 ` Maxim Mikityanskiy ` (2 more replies) 2024-03-29 20:00 ` [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare patchwork-bot+netdevbpf 2 siblings, 3 replies; 11+ messages in thread From: Arnd Bergmann @ 2024-03-28 14:30 UTC (permalink / raw) To: linux-kernel, Saeed Mahameed, Leon Romanovsky, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nathan Chancellor, Jonathan Lemon, Maxim Mikityanskiy, Daniel Borkmann Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt, Tariq Toukan, Gal Pressman, netdev, linux-rdma, llvm From: Arnd Bergmann <arnd@arndb.de> When building with 64KB pages, clang points out that xsk->chunk_size can never be PAGE_SIZE: drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c:19:22: error: result of comparison of constant 65536 with expression of type 'u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (xsk->chunk_size > PAGE_SIZE || ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~ In older versions of this code, using PAGE_SIZE was the only possibility, so this would have never worked on 64KB page kernels, but the patch apparently did not address this case completely. As Maxim Mikityanskiy suggested, 64KB chunks are really not all that useful, so just shut up the warning by adding a cast. Fixes: 282c0c798f8e ("net/mlx5e: Allow XSK frames smaller than a page") Link: https://lore.kernel.org/netdev/20211013150232.2942146-1-arnd@kernel.org/ Link: https://lore.kernel.org/lkml/a7b27541-0ebb-4f2d-bd06-270a4d404613@app.fastmail.com/ Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c index 06592b9f0424..9240cfe25d10 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c @@ -28,8 +28,10 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params, struct mlx5e_xsk_param *xsk, struct mlx5_core_dev *mdev) { - /* AF_XDP doesn't support frames larger than PAGE_SIZE. */ - if (xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) { + /* AF_XDP doesn't support frames larger than PAGE_SIZE, + * and xsk->chunk_size is limited to 65535 bytes. + */ + if ((size_t)xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) { mlx5_core_err(mdev, "XSK chunk size %u out of bounds [%u, %lu]\n", xsk->chunk_size, MLX5E_MIN_XSK_CHUNK_SIZE, PAGE_SIZE); return false; -- 2.39.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 8/9] mlx5: stop warning for 64KB pages 2024-03-28 14:30 ` [PATCH 8/9] mlx5: stop warning for 64KB pages Arnd Bergmann @ 2024-03-28 15:37 ` Maxim Mikityanskiy 2024-03-28 22:09 ` Justin Stitt 2024-03-28 22:39 ` Tariq Toukan 2 siblings, 0 replies; 11+ messages in thread From: Maxim Mikityanskiy @ 2024-03-28 15:37 UTC (permalink / raw) To: Arnd Bergmann Cc: linux-kernel, Saeed Mahameed, Leon Romanovsky, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nathan Chancellor, Jonathan Lemon, Daniel Borkmann, Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt, Tariq Toukan, Gal Pressman, netdev, linux-rdma, llvm On Thu, 28 Mar 2024 at 15:30:46 +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > When building with 64KB pages, clang points out that xsk->chunk_size > can never be PAGE_SIZE: > > drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c:19:22: error: result of comparison of constant 65536 with expression of type 'u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] > if (xsk->chunk_size > PAGE_SIZE || > ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~ > > In older versions of this code, using PAGE_SIZE was the only > possibility, so this would have never worked on 64KB page kernels, > but the patch apparently did not address this case completely. > > As Maxim Mikityanskiy suggested, 64KB chunks are really not all that > useful, so just shut up the warning by adding a cast. > > Fixes: 282c0c798f8e ("net/mlx5e: Allow XSK frames smaller than a page") > Link: https://lore.kernel.org/netdev/20211013150232.2942146-1-arnd@kernel.org/ > Link: https://lore.kernel.org/lkml/a7b27541-0ebb-4f2d-bd06-270a4d404613@app.fastmail.com/ > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c > index 06592b9f0424..9240cfe25d10 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c > @@ -28,8 +28,10 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params, > struct mlx5e_xsk_param *xsk, > struct mlx5_core_dev *mdev) > { > - /* AF_XDP doesn't support frames larger than PAGE_SIZE. */ > - if (xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) { > + /* AF_XDP doesn't support frames larger than PAGE_SIZE, > + * and xsk->chunk_size is limited to 65535 bytes. > + */ > + if ((size_t)xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) { Acked-by: Maxim Mikityanskiy <maxtram95@gmail.com> > mlx5_core_err(mdev, "XSK chunk size %u out of bounds [%u, %lu]\n", xsk->chunk_size, > MLX5E_MIN_XSK_CHUNK_SIZE, PAGE_SIZE); > return false; > -- > 2.39.2 > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 8/9] mlx5: stop warning for 64KB pages 2024-03-28 14:30 ` [PATCH 8/9] mlx5: stop warning for 64KB pages Arnd Bergmann 2024-03-28 15:37 ` Maxim Mikityanskiy @ 2024-03-28 22:09 ` Justin Stitt 2024-03-28 22:21 ` Arnd Bergmann 2024-03-28 22:39 ` Tariq Toukan 2 siblings, 1 reply; 11+ messages in thread From: Justin Stitt @ 2024-03-28 22:09 UTC (permalink / raw) To: Arnd Bergmann Cc: linux-kernel, Saeed Mahameed, Leon Romanovsky, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nathan Chancellor, Jonathan Lemon, Maxim Mikityanskiy, Daniel Borkmann, Arnd Bergmann, Nick Desaulniers, Bill Wendling, Tariq Toukan, Gal Pressman, netdev, linux-rdma, llvm On Thu, Mar 28, 2024 at 7:32 AM Arnd Bergmann <arnd@kernel.org> wrote: > > From: Arnd Bergmann <arnd@arndb.de> > > When building with 64KB pages, clang points out that xsk->chunk_size > can never be PAGE_SIZE: This is under W=1 right? Otherwise this is a mighty annoying warning. > > drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c:19:22: error: result of comparison of constant 65536 with expression of type 'u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] > if (xsk->chunk_size > PAGE_SIZE || > ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~ > > In older versions of this code, using PAGE_SIZE was the only > possibility, so this would have never worked on 64KB page kernels, > but the patch apparently did not address this case completely. > > As Maxim Mikityanskiy suggested, 64KB chunks are really not all that > useful, so just shut up the warning by adding a cast. > > Fixes: 282c0c798f8e ("net/mlx5e: Allow XSK frames smaller than a page") > Link: https://lore.kernel.org/netdev/20211013150232.2942146-1-arnd@kernel.org/ > Link: https://lore.kernel.org/lkml/a7b27541-0ebb-4f2d-bd06-270a4d404613@app.fastmail.com/ > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Justin Stitt <justinstitt@google.com> > --- > drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c > index 06592b9f0424..9240cfe25d10 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c > @@ -28,8 +28,10 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params, > struct mlx5e_xsk_param *xsk, > struct mlx5_core_dev *mdev) > { > - /* AF_XDP doesn't support frames larger than PAGE_SIZE. */ > - if (xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) { > + /* AF_XDP doesn't support frames larger than PAGE_SIZE, > + * and xsk->chunk_size is limited to 65535 bytes. > + */ > + if ((size_t)xsk->chunk_size > PAGE_SIZE || xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE) { > mlx5_core_err(mdev, "XSK chunk size %u out of bounds [%u, %lu]\n", xsk->chunk_size, > MLX5E_MIN_XSK_CHUNK_SIZE, PAGE_SIZE); > return false; > -- > 2.39.2 > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 8/9] mlx5: stop warning for 64KB pages 2024-03-28 22:09 ` Justin Stitt @ 2024-03-28 22:21 ` Arnd Bergmann 0 siblings, 0 replies; 11+ messages in thread From: Arnd Bergmann @ 2024-03-28 22:21 UTC (permalink / raw) To: Justin Stitt, Arnd Bergmann Cc: linux-kernel, Saeed Mahameed, Leon Romanovsky, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nathan Chancellor, Jonathan Lemon, Maxim Mikityanskiy, Daniel Borkmann, Nick Desaulniers, Bill Wendling, Tariq Toukan, Gal Pressman, Netdev, linux-rdma, llvm On Thu, Mar 28, 2024, at 23:09, Justin Stitt wrote: > On Thu, Mar 28, 2024 at 7:32 AM Arnd Bergmann <arnd@kernel.org> wrote: >> >> From: Arnd Bergmann <arnd@arndb.de> >> >> When building with 64KB pages, clang points out that xsk->chunk_size >> can never be PAGE_SIZE: > > This is under W=1 right? Otherwise this is a mighty annoying warning. At the moment yes. I'm fairly sure that I've covered all the common cases with thousands of randconfig builds, so we should be able to make it the default when this series is fully merged. Arnd ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 8/9] mlx5: stop warning for 64KB pages 2024-03-28 14:30 ` [PATCH 8/9] mlx5: stop warning for 64KB pages Arnd Bergmann 2024-03-28 15:37 ` Maxim Mikityanskiy 2024-03-28 22:09 ` Justin Stitt @ 2024-03-28 22:39 ` Tariq Toukan 2 siblings, 0 replies; 11+ messages in thread From: Tariq Toukan @ 2024-03-28 22:39 UTC (permalink / raw) To: Arnd Bergmann, linux-kernel, Saeed Mahameed, Leon Romanovsky, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nathan Chancellor, Jonathan Lemon, Maxim Mikityanskiy, Daniel Borkmann Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt, Gal Pressman, netdev, linux-rdma, llvm, Tariq Toukan On 28/03/2024 16:30, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > When building with 64KB pages, clang points out that xsk->chunk_size > can never be PAGE_SIZE: > > drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c:19:22: error: result of comparison of constant 65536 with expression of type 'u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] > if (xsk->chunk_size > PAGE_SIZE || > ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~ > > In older versions of this code, using PAGE_SIZE was the only > possibility, so this would have never worked on 64KB page kernels, > but the patch apparently did not address this case completely. > > As Maxim Mikityanskiy suggested, 64KB chunks are really not all that > useful, so just shut up the warning by adding a cast. > > Fixes: 282c0c798f8e ("net/mlx5e: Allow XSK frames smaller than a page") > Link: https://lore.kernel.org/netdev/20211013150232.2942146-1-arnd@kernel.org/ > Link: https://lore.kernel.org/lkml/a7b27541-0ebb-4f2d-bd06-270a4d404613@app.fastmail.com/ > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Thanks for your patch. Reviewed-by: Tariq Toukan <tariqt@nvidia.com> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare 2024-03-28 14:30 [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare Arnd Bergmann 2024-03-28 14:30 ` [PATCH 7/9] infiniband: uverbs: avoid out-of-range warnings Arnd Bergmann 2024-03-28 14:30 ` [PATCH 8/9] mlx5: stop warning for 64KB pages Arnd Bergmann @ 2024-03-29 20:00 ` patchwork-bot+netdevbpf 2 siblings, 0 replies; 11+ messages in thread From: patchwork-bot+netdevbpf @ 2024-03-29 20:00 UTC (permalink / raw) To: Arnd Bergmann Cc: linux-kernel, arnd, idryomov, dongsheng.yang, axboe, jgg, leon, agk, snitzer, mpatocka, dm-devel, saeedm, davem, edumazet, kuba, pabeni, xiubli, jlayton, konishi.ryusuke, dvyukov, andreyknvl, dsahern, masahiroy, nathan, nicolas, ndesaulniers, morbo, justinstitt, keescook, gustavoars, tariqt, ceph-devel, linux-block, linux-rdma, netdev, linux-nilfs, kasan-dev, linux-kbuild, llvm Hello: This series was applied to netdev/net-next.git (main) by Jakub Kicinski <kuba@kernel.org>: On Thu, 28 Mar 2024 15:30:38 +0100 you wrote: > From: Arnd Bergmann <arnd@arndb.de> > > The warning option was introduced a few years ago but left disabled > by default. All of the actual bugs that this has found have been > fixed in the meantime, and this series should address the remaining > false-positives, as tested on arm/arm64/x86 randconfigs as well as > allmodconfig builds for all architectures supported by clang. > > [...] Here is the summary with links: - [2/9] libceph: avoid clang out-of-range warning (no matching commit) - [5/9] ipv4: tcp_output: avoid warning about NET_ADD_STATS (no matching commit) - [8/9] mlx5: stop warning for 64KB pages https://git.kernel.org/netdev/net-next/c/a5535e533694 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-04-03 20:16 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-03-28 14:30 [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare Arnd Bergmann 2024-03-28 14:30 ` [PATCH 7/9] infiniband: uverbs: avoid out-of-range warnings Arnd Bergmann 2024-03-28 22:12 ` Justin Stitt 2024-04-03 15:45 ` Jason Gunthorpe 2024-04-03 20:16 ` Arnd Bergmann 2024-03-28 14:30 ` [PATCH 8/9] mlx5: stop warning for 64KB pages Arnd Bergmann 2024-03-28 15:37 ` Maxim Mikityanskiy 2024-03-28 22:09 ` Justin Stitt 2024-03-28 22:21 ` Arnd Bergmann 2024-03-28 22:39 ` Tariq Toukan 2024-03-29 20:00 ` [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox