fuse: ioctl: fix comparison in fuse_setup_measure_verity()
PATCH 1/1 fuse: ioctl: fix comparison in fuse_setup_measure_verity()
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.
--- fs/fuse/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/ioctl.c +1 -1
@@ -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;
Signature · 1 line
2.55.0
Miklos Szeredi
maintainerQuoted 8 lines · Ali Nasrollahi
Clang reports a warning in
fuse_setup_measure_verity()infs/fuse/ioctl.cwhen comparing the__u16 digest_sizewithSIZE_MAXminus the size ofstruct 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
Quoted 6 lines · Miklos Szeredi
Quoted 5 lines · Ali Nasrollahi
Clang reports a warning in
fuse_setup_measure_verity()infs/fuse/ioctl.cwhen comparing the__u16 digest_sizewithSIZE_MAXminus the size ofstruct fsverity_digest:
Quoted 6 lines
Quoted 3 lines
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