lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdknKQaKL=GLLktmx6h5UE1waiKED-F=_7h+keGq9jx4dQ@mail.gmail.com>
Date:   Mon, 25 Jun 2018 13:12:13 -0400
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     joe@...ches.com
Cc:     pbonzini@...hat.com, Matthias Kaehlcke <mka@...omium.org>,
        rkrcmar@...hat.com, Thomas Gleixner <tglx@...utronix.de>,
        hpa@...or.com, x86@...nel.org, kvm@...r.kernel.org,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] kvm: x86: mmu: Add cast to negated bitmasks in update_permission_bitmask()

On Mon, Jun 25, 2018 at 1:05 PM Joe Perches <joe@...ches.com> wrote:
>
> On Mon, 2018-06-25 at 12:47 -0400, Nick Desaulniers wrote:
> > On Mon, Jun 25, 2018 at 12:05 PM Paolo Bonzini <pbonzini@...hat.com> wrote:
> > >
> > > On 19/06/2018 21:25, Matthias Kaehlcke wrote:
> > > > update_permission_bitmask() negates u8 bitmask values and assigns them
> > > > to variables of type u8. Since the MSB is set in the bitmask values the
> > > > compiler expands the negated values to int, which then is assigned to
> > > > an u8 variable. Cast the negated value back to u8.
> > > >
> > > > This fixes several warnings like this when building with clang:
> > > >
> > > > arch/x86/kvm/mmu.c:4266:39: error: implicit conversion from 'int' to 'u8'
> > > >   (aka 'unsigned char') changes value from -205 to 51 [-Werror,
> > > >   -Wconstant-conversion]
> > > >     u8 wf = (pfec & PFERR_WRITE_MASK) ? ~w : 0;
> > > >        ~~                               ^~
> > > >
> > > > (gcc also raises a warning (see https://godbolt.org/g/6JWfWk), however it
> > > > doesn't seem to be universally enabled)
> > > >
> > > > Suggested-by: Nick Desaulniers <ndesaulniers@...gle.com>
> > > > Signed-off-by: Matthias Kaehlcke <mka@...omium.org>
> > > > ---
> > > > Changes in v2:
> > > > - negate the bitmask at initialization and rename variables to not_X
> > >
> > > The patch is not that bad, but I'd like to get confirmation that other
> > > maintainers are applying fixes like this.  Honestly I'm not really
> > > impressed by most new clang warnings, these days.
> >
> > Here's an actual bug this warning caught applied to drivers/input/:
> >
> > dae1a432ab1f ("Input: mousedev - fix implicit conversion warning"):
> > https://patchwork.kernel.org/patch/9753771/
>
> What bug is that?
>
> $ cat test.c
> #include <stdio.h>
> #include <stdlib.h>
> #include <memory.h>
>
> int main(int argc, char **argv)
> {
>         static const signed char a[3] = {0x60, 3, 200};
>         static const unsigned char b[3] = {0x60, 3, 200};
>
>         printf("a and b are %s\n",
>                memcmp(a, b, 3) == 0 ? "identical" : "different");
> }
> $ gcc test.c
> $ ./a.out
> a and b are identical
>

Good point, poor choice of example on my part.
-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ