Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] vboxsf: fix comparison of signed char constant with unsigned char array elements
@ 2020-09-15 16:03 Colin King
  2020-09-16  6:14 ` Hans de Goede
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2020-09-15 16:03 UTC (permalink / raw)
  To: Hans de Goede, Christoph Hellwig, Al Viro, linux-fsdevel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The comparison of signed char constants with unsigned char array
elements leads to checks that are always false. Fix this by declaring
the VBSF_MOUNT_SIGNATURE_BYTE* macros as octal unsigned int constants
rather than as signed char constants. (Argueably the U is not necessarily
required, but add it to be really clear of intent).

Addresses-Coverity: ("Operands don't affect result")
Fixes: 0fd169576648 ("fs: Add VirtualBox guest shared folder (vboxsf) support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/vboxsf/super.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c
index 25aade344192..986efcb29cc2 100644
--- a/fs/vboxsf/super.c
+++ b/fs/vboxsf/super.c
@@ -21,10 +21,10 @@
 
 #define VBOXSF_SUPER_MAGIC 0x786f4256 /* 'VBox' little endian */
 
-#define VBSF_MOUNT_SIGNATURE_BYTE_0 ('\000')
-#define VBSF_MOUNT_SIGNATURE_BYTE_1 ('\377')
-#define VBSF_MOUNT_SIGNATURE_BYTE_2 ('\376')
-#define VBSF_MOUNT_SIGNATURE_BYTE_3 ('\375')
+#define VBSF_MOUNT_SIGNATURE_BYTE_0 0000U
+#define VBSF_MOUNT_SIGNATURE_BYTE_1 0377U
+#define VBSF_MOUNT_SIGNATURE_BYTE_2 0376U
+#define VBSF_MOUNT_SIGNATURE_BYTE_3 0375U
 
 static int follow_symlinks;
 module_param(follow_symlinks, int, 0444);
-- 
2.27.0


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

* Re: [PATCH] vboxsf: fix comparison of signed char constant with unsigned char array elements
  2020-09-15 16:03 [PATCH] vboxsf: fix comparison of signed char constant with unsigned char array elements Colin King
@ 2020-09-16  6:14 ` Hans de Goede
  2020-09-16  7:20   ` Sedat Dilek
  0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2020-09-16  6:14 UTC (permalink / raw)
  To: Colin King, Christoph Hellwig, Al Viro, linux-fsdevel
  Cc: kernel-janitors, linux-kernel

Hi,

On 9/15/20 6:03 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The comparison of signed char constants with unsigned char array
> elements leads to checks that are always false. Fix this by declaring
> the VBSF_MOUNT_SIGNATURE_BYTE* macros as octal unsigned int constants
> rather than as signed char constants. (Argueably the U is not necessarily
> required, but add it to be really clear of intent).
> 
> Addresses-Coverity: ("Operands don't affect result")
> Fixes: 0fd169576648 ("fs: Add VirtualBox guest shared folder (vboxsf) support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

A fix for this has already been queued up:

https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git/log/?h=fixes

Explicit nack for this one, since it will still apply, but combined
with the other fix, it will re-break things.

Regards,

Hans



> ---
>   fs/vboxsf/super.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c
> index 25aade344192..986efcb29cc2 100644
> --- a/fs/vboxsf/super.c
> +++ b/fs/vboxsf/super.c
> @@ -21,10 +21,10 @@
>   
>   #define VBOXSF_SUPER_MAGIC 0x786f4256 /* 'VBox' little endian */
>   
> -#define VBSF_MOUNT_SIGNATURE_BYTE_0 ('\000')
> -#define VBSF_MOUNT_SIGNATURE_BYTE_1 ('\377')
> -#define VBSF_MOUNT_SIGNATURE_BYTE_2 ('\376')
> -#define VBSF_MOUNT_SIGNATURE_BYTE_3 ('\375')
> +#define VBSF_MOUNT_SIGNATURE_BYTE_0 0000U
> +#define VBSF_MOUNT_SIGNATURE_BYTE_1 0377U
> +#define VBSF_MOUNT_SIGNATURE_BYTE_2 0376U
> +#define VBSF_MOUNT_SIGNATURE_BYTE_3 0375U
>   
>   static int follow_symlinks;
>   module_param(follow_symlinks, int, 0444);
> 


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

* Re: [PATCH] vboxsf: fix comparison of signed char constant with unsigned char array elements
  2020-09-16  6:14 ` Hans de Goede
@ 2020-09-16  7:20   ` Sedat Dilek
  0 siblings, 0 replies; 3+ messages in thread
From: Sedat Dilek @ 2020-09-16  7:20 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Colin King, Christoph Hellwig, Al Viro, linux-fsdevel,
	kernel-janitors, linux-kernel

On Wed, Sep 16, 2020 at 8:16 AM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Hi,
>
> On 9/15/20 6:03 PM, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > The comparison of signed char constants with unsigned char array
> > elements leads to checks that are always false. Fix this by declaring
> > the VBSF_MOUNT_SIGNATURE_BYTE* macros as octal unsigned int constants
> > rather than as signed char constants. (Argueably the U is not necessarily
> > required, but add it to be really clear of intent).
> >
> > Addresses-Coverity: ("Operands don't affect result")
> > Fixes: 0fd169576648 ("fs: Add VirtualBox guest shared folder (vboxsf) support")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> A fix for this has already been queued up:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git/log/?h=fixes
>
> Explicit nack for this one, since it will still apply, but combined
> with the other fix, it will re-break things.
>

Hans, your patch is from 2020-08-25 and in a "fixes" Git branch of vfs
- why wasn't it applied to Linux 5.9?

- Sedat -

> Regards,
>
> Hans
>
>
>
> > ---
> >   fs/vboxsf/super.c | 8 ++++----
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c
> > index 25aade344192..986efcb29cc2 100644
> > --- a/fs/vboxsf/super.c
> > +++ b/fs/vboxsf/super.c
> > @@ -21,10 +21,10 @@
> >
> >   #define VBOXSF_SUPER_MAGIC 0x786f4256 /* 'VBox' little endian */
> >
> > -#define VBSF_MOUNT_SIGNATURE_BYTE_0 ('\000')
> > -#define VBSF_MOUNT_SIGNATURE_BYTE_1 ('\377')
> > -#define VBSF_MOUNT_SIGNATURE_BYTE_2 ('\376')
> > -#define VBSF_MOUNT_SIGNATURE_BYTE_3 ('\375')
> > +#define VBSF_MOUNT_SIGNATURE_BYTE_0 0000U
> > +#define VBSF_MOUNT_SIGNATURE_BYTE_1 0377U
> > +#define VBSF_MOUNT_SIGNATURE_BYTE_2 0376U
> > +#define VBSF_MOUNT_SIGNATURE_BYTE_3 0375U
> >
> >   static int follow_symlinks;
> >   module_param(follow_symlinks, int, 0444);
> >
>

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

end of thread, other threads:[~2020-09-16  7:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 16:03 [PATCH] vboxsf: fix comparison of signed char constant with unsigned char array elements Colin King
2020-09-16  6:14 ` Hans de Goede
2020-09-16  7:20   ` Sedat Dilek

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).