The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] fuse: ioctl: fix comparison in fuse_setup_measure_verity()
@ 2026-08-13  7:06 Ali Nasrollahi
  2026-08-18  8:53 ` Miklos Szeredi
  0 siblings, 1 reply; 3+ messages in thread
From: Ali Nasrollahi @ 2026-08-13  7:06 UTC (permalink / raw)
  To: fuse-devel; +Cc: miklos, linux-kernel, Ali Nasrollahi

Clang reports a warning in fuse_setup_measure_verity() in
fs/fuse/ioctl.c when comparing the `__u16 digest_size` with SIZE_MAX
minus the size of `struct fsverity_digest`:

	warning: result of comparison of constant 18446744073709551611
	with expression of type '__u16' (aka 'unsigned short') is always
	false [-Wtautological-constant-out-of-range-compare]

This was first observed while building an x86_64 kernel with Clang and
W=1. Since -Werror was enabled in my build, the warning caused the build
to fail.

However, the same warning can also be reproduced with the same build
options using tinyconfig with FUSE enabled, so this is not specific to
the kernel configuration used in the original build.

The comparison is between the 16-bit digest_size and a size_t-sized
constant. Cast digest_size to size_t so that the comparison is performed
using the same type as the size calculation.

Signed-off-by: Ali Nasrollahi <A.Nasrolahi01@gmail.com>
---
 fs/fuse/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c
index 3614ea603913..3487e30d997c 100644
--- a/fs/fuse/ioctl.c
+++ b/fs/fuse/ioctl.c
@@ -130,7 +130,7 @@ static int fuse_setup_measure_verity(unsigned long arg, struct iovec *iov)
 	if (copy_from_user(&digest_size, &uarg->digest_size, sizeof(digest_size)))
 		return -EFAULT;
 
-	if (digest_size > SIZE_MAX - sizeof(struct fsverity_digest))
+	if ((size_t)digest_size > SIZE_MAX - sizeof(struct fsverity_digest))
 		return -EINVAL;
 
 	iov->iov_len = sizeof(struct fsverity_digest) + digest_size;
-- 
2.55.0


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

* Re: [PATCH] fuse: ioctl: fix comparison in fuse_setup_measure_verity()
  2026-08-13  7:06 [PATCH] fuse: ioctl: fix comparison in fuse_setup_measure_verity() Ali Nasrollahi
@ 2026-08-18  8:53 ` Miklos Szeredi
  2026-08-18 16:03   ` Ali Nasrollahi
  0 siblings, 1 reply; 3+ messages in thread
From: Miklos Szeredi @ 2026-08-18  8:53 UTC (permalink / raw)
  To: Ali Nasrollahi; +Cc: fuse-devel, linux-kernel

On Thu, 13 Aug 2026 at 09:07, Ali Nasrollahi <a.nasrolahi01@gmail.com> wrote:
>
> Clang reports a warning in fuse_setup_measure_verity() in
> fs/fuse/ioctl.c when comparing the `__u16 digest_size` with SIZE_MAX
> minus the size of `struct fsverity_digest`:
>
>         warning: result of comparison of constant 18446744073709551611
>         with expression of type '__u16' (aka 'unsigned short') is always
>         false [-Wtautological-constant-out-of-range-compare]

The warning is right: that condition is never going to succeed.  So
just remove it?

Thanks,
Miklos

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

* Re: [PATCH] fuse: ioctl: fix comparison in fuse_setup_measure_verity()
  2026-08-18  8:53 ` Miklos Szeredi
@ 2026-08-18 16:03   ` Ali Nasrollahi
  0 siblings, 0 replies; 3+ messages in thread
From: Ali Nasrollahi @ 2026-08-18 16:03 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: fuse-devel, linux-kernel

On 26/08/18 10:53AM, Miklos Szeredi wrote:
> On Thu, 13 Aug 2026 at 09:07, Ali Nasrollahi <a.nasrolahi01@gmail.com> wrote:
> >
> > Clang reports a warning in fuse_setup_measure_verity() in
> > fs/fuse/ioctl.c when comparing the `__u16 digest_size` with SIZE_MAX
> > minus the size of `struct fsverity_digest`:
> >
> >         warning: result of comparison of constant 18446744073709551611
> >         with expression of type '__u16' (aka 'unsigned short') is always
> >         false [-Wtautological-constant-out-of-range-compare]
> 
> The warning is right: that condition is never going to succeed.  So
> just remove it?

Well, I wasn't sure why it was there in the first place, so I didn't want
to change the logic. So I'll send the v2 considering your comment.

Thanks,
    Ali

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

end of thread, other threads:[~2026-08-18 16:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13  7:06 [PATCH] fuse: ioctl: fix comparison in fuse_setup_measure_verity() Ali Nasrollahi
2026-08-18  8:53 ` Miklos Szeredi
2026-08-18 16:03   ` Ali Nasrollahi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox