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
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
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 >
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; > > /*
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
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
© 2016 - 2026 Red Hat, Inc.