linux-nilfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare
@ 2024-03-28 14:30 Arnd Bergmann
  2024-03-28 14:30 ` [PATCH 6/9] nilfs2: fix 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; 9+ 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] 9+ messages in thread

* [PATCH 6/9] nilfs2: fix 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 15:21   ` Philipp Stanner
                     ` (3 more replies)
  2024-03-29 20:00 ` [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare patchwork-bot+netdevbpf
  1 sibling, 4 replies; 9+ messages in thread
From: Arnd Bergmann @ 2024-03-28 14:30 UTC (permalink / raw)
  To: linux-kernel, Ryusuke Konishi, Nathan Chancellor
  Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Andrew Morton, Philipp Stanner, Christian Brauner, Jeff Layton,
	Thorsten Blum, linux-nilfs, llvm

From: Arnd Bergmann <arnd@arndb.de>

clang-14 points out that v_size is always smaller than a 64KB
page size if that is configured by the CPU architecture:

fs/nilfs2/ioctl.c:63:19: 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 (argv->v_size > PAGE_SIZE)
            ~~~~~~~~~~~~ ^ ~~~~~~~~~

This is ok, so just shut up that warning with a cast.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/nilfs2/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index f1a01c191cf5..8be471ce4f19 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -60,7 +60,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
 	if (argv->v_nmembs == 0)
 		return 0;
 
-	if (argv->v_size > PAGE_SIZE)
+	if ((size_t)argv->v_size > PAGE_SIZE)
 		return -EINVAL;
 
 	/*
-- 
2.39.2


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

* Re: [PATCH 6/9] nilfs2: fix out-of-range warning
  2024-03-28 14:30 ` [PATCH 6/9] nilfs2: fix out-of-range warning Arnd Bergmann
@ 2024-03-28 15:21   ` Philipp Stanner
  2024-03-28 16:12     ` Arnd Bergmann
  2024-03-28 22:04   ` Justin Stitt
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Philipp Stanner @ 2024-03-28 15:21 UTC (permalink / raw)
  To: Arnd Bergmann, linux-kernel, Ryusuke Konishi, Nathan Chancellor
  Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Andrew Morton, Christian Brauner, Jeff Layton, Thorsten Blum,
	linux-nilfs, llvm, pstanner

On Thu, 2024-03-28 at 15:30 +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang-14 points out that v_size is always smaller than a 64KB
> page size if that is configured by the CPU architecture:
> 
> fs/nilfs2/ioctl.c:63:19: 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 (argv->v_size > PAGE_SIZE)
>             ~~~~~~~~~~~~ ^ ~~~~~~~~~
> 
> This is ok, so just shut up that warning with a cast.

nit:
It's not a warning, but actually a compile error, right?

(no idea why they make that an error btw. Warning would be perfectly
fine)

> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Should / could that be backported to stable kernels in case people
start building those with clang-14?

Regards,
P.

> ---
>  fs/nilfs2/ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
> index f1a01c191cf5..8be471ce4f19 100644
> --- a/fs/nilfs2/ioctl.c
> +++ b/fs/nilfs2/ioctl.c
> @@ -60,7 +60,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs
> *nilfs,
>         if (argv->v_nmembs == 0)
>                 return 0;
>  
> -       if (argv->v_size > PAGE_SIZE)
> +       if ((size_t)argv->v_size > PAGE_SIZE)
>                 return -EINVAL;
>  
>         /*


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

* Re: [PATCH 6/9] nilfs2: fix out-of-range warning
  2024-03-28 15:21   ` Philipp Stanner
@ 2024-03-28 16:12     ` Arnd Bergmann
  0 siblings, 0 replies; 9+ messages in thread
From: Arnd Bergmann @ 2024-03-28 16:12 UTC (permalink / raw)
  To: Philipp Stanner, Arnd Bergmann, linux-kernel, Ryusuke Konishi,
	Nathan Chancellor
  Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, Andrew Morton,
	Christian Brauner, Jeff Layton, Thorsten Blum, linux-nilfs, llvm

On Thu, Mar 28, 2024, at 16:21, Philipp Stanner wrote:
> On Thu, 2024-03-28 at 15:30 +0100, Arnd Bergmann wrote:
>> 
>> This is ok, so just shut up that warning with a cast.
>
> nit:
> It's not a warning, but actually a compile error, right?

I build with CONFIG_WERROR=y, which turns all warnings
into errors. It's just a warning without that, and is
currently only enabled when building with 'make W=1',
though the point of my series is to have it always enabled.

> (no idea why they make that an error btw. Warning would be perfectly
> fine)
>
>> 
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Should / could that be backported to stable kernels in case people
> start building those with clang-14?

It's clearly harmless and could be backported, but it
is not needed either since older kernels will keep the
option as part of W=1, not the default.

      Arnd

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

* Re: [PATCH 6/9] nilfs2: fix out-of-range warning
  2024-03-28 14:30 ` [PATCH 6/9] nilfs2: fix out-of-range warning Arnd Bergmann
  2024-03-28 15:21   ` Philipp Stanner
@ 2024-03-28 22:04   ` Justin Stitt
  2024-03-28 22:25     ` Arnd Bergmann
  2024-03-29  9:20   ` Ryusuke Konishi
  2024-04-01  8:50   ` (subset) " Christian Brauner
  3 siblings, 1 reply; 9+ messages in thread
From: Justin Stitt @ 2024-03-28 22:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, Ryusuke Konishi, Nathan Chancellor, Arnd Bergmann,
	Nick Desaulniers, Bill Wendling, Andrew Morton, Philipp Stanner,
	Christian Brauner, Jeff Layton, Thorsten Blum, linux-nilfs, llvm

On Thu, Mar 28, 2024 at 7:32 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang-14 points out that v_size is always smaller than a 64KB
> page size if that is configured by the CPU architecture:

Is this only with clang-14?

>
> fs/nilfs2/ioctl.c:63:19: 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 (argv->v_size > PAGE_SIZE)
>             ~~~~~~~~~~~~ ^ ~~~~~~~~~
>
> This is ok, so just shut up that warning with a cast.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

My question out of curiosity aside,

Reviewed-by: Justin Stitt <justinstitt@google.com>

> ---
>  fs/nilfs2/ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
> index f1a01c191cf5..8be471ce4f19 100644
> --- a/fs/nilfs2/ioctl.c
> +++ b/fs/nilfs2/ioctl.c
> @@ -60,7 +60,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
>         if (argv->v_nmembs == 0)
>                 return 0;
>
> -       if (argv->v_size > PAGE_SIZE)
> +       if ((size_t)argv->v_size > PAGE_SIZE)
>                 return -EINVAL;
>
>         /*
> --
> 2.39.2
>

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

* Re: [PATCH 6/9] nilfs2: fix out-of-range warning
  2024-03-28 22:04   ` Justin Stitt
@ 2024-03-28 22:25     ` Arnd Bergmann
  0 siblings, 0 replies; 9+ messages in thread
From: Arnd Bergmann @ 2024-03-28 22:25 UTC (permalink / raw)
  To: Justin Stitt, Arnd Bergmann
  Cc: linux-kernel, Ryusuke Konishi, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Andrew Morton, Philipp Stanner,
	Christian Brauner, Jeff Layton, Thorsten Blum, linux-nilfs, llvm

On Thu, Mar 28, 2024, at 23:04, Justin Stitt wrote:
> On Thu, Mar 28, 2024 at 7:32 AM Arnd Bergmann <arnd@kernel.org> wrote:
>>
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> clang-14 points out that v_size is always smaller than a 64KB
>> page size if that is configured by the CPU architecture:
>
> Is this only with clang-14?

No, it should be every version since then. I checked my
randconfig tree and found that I originally committed this
patch in September 2021 when I was first testing prerelease
clang-14 builds. I sent a couple of fixes for this class
of warnings then, but for some reason not this one.

      Arnd

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

* Re: [PATCH 6/9] nilfs2: fix out-of-range warning
  2024-03-28 14:30 ` [PATCH 6/9] nilfs2: fix out-of-range warning Arnd Bergmann
  2024-03-28 15:21   ` Philipp Stanner
  2024-03-28 22:04   ` Justin Stitt
@ 2024-03-29  9:20   ` Ryusuke Konishi
  2024-04-01  8:50   ` (subset) " Christian Brauner
  3 siblings, 0 replies; 9+ messages in thread
From: Ryusuke Konishi @ 2024-03-29  9:20 UTC (permalink / raw)
  To: Arnd Bergmann, Andrew Morton
  Cc: linux-kernel, Nathan Chancellor, Arnd Bergmann, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Philipp Stanner, Christian Brauner,
	Jeff Layton, Thorsten Blum, linux-nilfs, llvm

On Thu, Mar 28, 2024 at 11:32 PM Arnd Bergmann wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang-14 points out that v_size is always smaller than a 64KB
> page size if that is configured by the CPU architecture:
>
> fs/nilfs2/ioctl.c:63:19: 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 (argv->v_size > PAGE_SIZE)
>             ~~~~~~~~~~~~ ^ ~~~~~~~~~
>
> This is ok, so just shut up that warning with a cast.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  fs/nilfs2/ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
> index f1a01c191cf5..8be471ce4f19 100644
> --- a/fs/nilfs2/ioctl.c
> +++ b/fs/nilfs2/ioctl.c
> @@ -60,7 +60,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
>         if (argv->v_nmembs == 0)
>                 return 0;
>
> -       if (argv->v_size > PAGE_SIZE)
> +       if ((size_t)argv->v_size > PAGE_SIZE)
>                 return -EINVAL;
>
>         /*
> --
> 2.39.2
>

Andrew, could you please apply this to the -mm tree along with the
following tags and Justin's reviewed-by tag?

Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Fixes: 3358b4aaa84f ("nilfs2: fix problems of memory allocation in ioctl")

Thank you, Arnd.
I didn't notice this warning existed depending on the environment.

Ryusuke Konishi

^ permalink raw reply	[flat|nested] 9+ 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 6/9] nilfs2: fix out-of-range warning Arnd Bergmann
@ 2024-03-29 20:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 9+ 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] 9+ messages in thread

* Re: (subset) [PATCH 6/9] nilfs2: fix out-of-range warning
  2024-03-28 14:30 ` [PATCH 6/9] nilfs2: fix out-of-range warning Arnd Bergmann
                     ` (2 preceding siblings ...)
  2024-03-29  9:20   ` Ryusuke Konishi
@ 2024-04-01  8:50   ` Christian Brauner
  3 siblings, 0 replies; 9+ messages in thread
From: Christian Brauner @ 2024-04-01  8:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Christian Brauner, Arnd Bergmann, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Andrew Morton, Philipp Stanner,
	Jeff Layton, Thorsten Blum, linux-nilfs, llvm, linux-kernel,
	Ryusuke Konishi, Nathan Chancellor

On Thu, 28 Mar 2024 15:30:44 +0100, Arnd Bergmann wrote:
> clang-14 points out that v_size is always smaller than a 64KB
> page size if that is configured by the CPU architecture:
> 
> fs/nilfs2/ioctl.c:63:19: 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 (argv->v_size > PAGE_SIZE)
>             ~~~~~~~~~~~~ ^ ~~~~~~~~~
> 
> [...]

Applied to the vfs.misc branch of the vfs/vfs.git tree.
Patches in the vfs.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc

[6/9] nilfs2: fix out-of-range warning
      https://git.kernel.org/vfs/vfs/c/d20180d5dd10

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

end of thread, other threads:[~2024-04-01  8:50 UTC | newest]

Thread overview: 9+ 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 6/9] nilfs2: fix out-of-range warning Arnd Bergmann
2024-03-28 15:21   ` Philipp Stanner
2024-03-28 16:12     ` Arnd Bergmann
2024-03-28 22:04   ` Justin Stitt
2024-03-28 22:25     ` Arnd Bergmann
2024-03-29  9:20   ` Ryusuke Konishi
2024-04-01  8:50   ` (subset) " Christian Brauner
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;
as well as URLs for NNTP newsgroup(s).