* [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare
@ 2024-03-28 14:30 Arnd Bergmann
2024-03-28 14:30 ` [PATCH 3/9] rbd: avoid out-of-range warning Arnd Bergmann
2024-03-29 20:00 ` [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ 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] 5+ messages in thread
* [PATCH 3/9] rbd: avoid out-of-range warning
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 14:53 ` Alex Elder
2024-03-29 20:00 ` [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2024-03-28 14:30 UTC (permalink / raw)
To: linux-kernel, Ilya Dryomov, Jens Axboe, Nathan Chancellor,
Alex Elder, Josh Durgin
Cc: Arnd Bergmann, Dongsheng Yang, Nick Desaulniers, Bill Wendling,
Justin Stitt, Hannes Reinecke, Christian Brauner,
Christophe JAILLET, Ricardo B. Marliere, Jinjie Ruan, Alex Elder,
ceph-devel, linux-block, llvm
From: Arnd Bergmann <arnd@arndb.de>
clang-14 points out that the range check is always true on 64-bit
architectures since a u32 is not greater than the allowed size:
drivers/block/rbd.c:6079:17: error: result of comparison of constant 2305843009213693948 with expression of type 'u32' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context))
~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is harmless, so just change the type of the temporary to size_t
to shut up that warning.
Fixes: bb23e37acb2a ("rbd: refactor rbd_header_from_disk()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/block/rbd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 26ff5cd2bf0a..cb25ee513ada 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -6062,7 +6062,7 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev,
void *p;
void *end;
u64 seq;
- u32 snap_count;
+ size_t snap_count;
struct ceph_snap_context *snapc;
u32 i;
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/9] rbd: avoid out-of-range warning
2024-03-28 14:30 ` [PATCH 3/9] rbd: avoid out-of-range warning Arnd Bergmann
@ 2024-03-28 14:53 ` Alex Elder
2024-03-29 0:05 ` Xiubo Li
0 siblings, 1 reply; 5+ messages in thread
From: Alex Elder @ 2024-03-28 14:53 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel, Ilya Dryomov, Jens Axboe,
Nathan Chancellor, Alex Elder, Josh Durgin
Cc: Arnd Bergmann, Dongsheng Yang, Nick Desaulniers, Bill Wendling,
Justin Stitt, Hannes Reinecke, Christian Brauner,
Christophe JAILLET, Ricardo B. Marliere, Jinjie Ruan, Alex Elder,
ceph-devel, linux-block, llvm
On 3/28/24 9:30 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang-14 points out that the range check is always true on 64-bit
> architectures since a u32 is not greater than the allowed size:
>
> drivers/block/rbd.c:6079:17: error: result of comparison of constant 2305843009213693948 with expression of type 'u32' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
w
> ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> This is harmless, so just change the type of the temporary to size_t
> to shut up that warning.
This fixes the warning, but then the now size_t value is passed
to ceph_decode_32_safe(), which implies a different type conversion.
That too is not harmful, but...
Could we just cast the value in the comparison instead?
if ((size_t)snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context))
You could drop the space between sizeof and ( while
you're at it (I always used the space back then).
-Alex
>
> Fixes: bb23e37acb2a ("rbd: refactor rbd_header_from_disk()")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/block/rbd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 26ff5cd2bf0a..cb25ee513ada 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -6062,7 +6062,7 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev,
> void *p;
> void *end;
> u64 seq;
> - u32 snap_count;
> + size_t snap_count;
> struct ceph_snap_context *snapc;
> u32 i;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/9] rbd: avoid out-of-range warning
2024-03-28 14:53 ` Alex Elder
@ 2024-03-29 0:05 ` Xiubo Li
0 siblings, 0 replies; 5+ messages in thread
From: Xiubo Li @ 2024-03-29 0:05 UTC (permalink / raw)
To: Alex Elder, Arnd Bergmann, linux-kernel, Ilya Dryomov, Jens Axboe,
Nathan Chancellor, Alex Elder, Josh Durgin
Cc: Arnd Bergmann, Dongsheng Yang, Nick Desaulniers, Bill Wendling,
Justin Stitt, Hannes Reinecke, Christian Brauner,
Christophe JAILLET, Ricardo B. Marliere, Jinjie Ruan, Alex Elder,
ceph-devel, linux-block, llvm
On 3/28/24 22:53, Alex Elder wrote:
> On 3/28/24 9:30 AM, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> clang-14 points out that the range check is always true on 64-bit
>> architectures since a u32 is not greater than the allowed size:
>>
>> drivers/block/rbd.c:6079:17: error: result of comparison of constant
>> 2305843009213693948 with expression of type 'u32' (aka 'unsigned
>> int') is always false
>> [-Werror,-Wtautological-constant-out-of-range-compare]
> w
>> ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> This is harmless, so just change the type of the temporary to size_t
>> to shut up that warning.
>
> This fixes the warning, but then the now size_t value is passed
> to ceph_decode_32_safe(), which implies a different type conversion.
> That too is not harmful, but...
>
> Could we just cast the value in the comparison instead?
>
> if ((size_t)snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context))
>
> You could drop the space between sizeof and ( while
> you're at it (I always used the space back then).
>
Agree.
- Xiubo
> -Alex
>
>>
>> Fixes: bb23e37acb2a ("rbd: refactor rbd_header_from_disk()")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>> drivers/block/rbd.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
>> index 26ff5cd2bf0a..cb25ee513ada 100644
>> --- a/drivers/block/rbd.c
>> +++ b/drivers/block/rbd.c
>> @@ -6062,7 +6062,7 @@ static int rbd_dev_v2_snap_context(struct
>> rbd_device *rbd_dev,
>> void *p;
>> void *end;
>> u64 seq;
>> - u32 snap_count;
>> + size_t snap_count;
>> struct ceph_snap_context *snapc;
>> u32 i;
>
>
^ permalink raw reply [flat|nested] 5+ 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 3/9] rbd: avoid out-of-range warning Arnd Bergmann
@ 2024-03-29 20:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ 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] 5+ messages in thread
end of thread, other threads:[~2024-03-29 20:00 UTC | newest]
Thread overview: 5+ 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 3/9] rbd: avoid out-of-range warning Arnd Bergmann
2024-03-28 14:53 ` Alex Elder
2024-03-29 0:05 ` Xiubo Li
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