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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 25 Jun 2018 10:35:02 -0700
From:   Matthias Kaehlcke <mka@...omium.org>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     Radim Krčmář <rkrcmar@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        "H . Peter Anvin" <hpa@...or.com>, x86@...nel.org,
        kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Joe Perches <joe@...ches.com>
Subject: Re: [PATCH v2] kvm: x86: mmu: Add cast to negated bitmasks in
 update_permission_bitmask()

Hi Paolo,

On Mon, Jun 25, 2018 at 06:05:01PM +0200, Paolo Bonzini 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.

Some other instances of the warning that have been addressed are:

commit 644d87dccdc69cf79834a72ed0c889580d6af32a
Author: Stefan Agner <stefan@...er.ch>
Date:   Thu Apr 5 16:25:38 2018 -0700

    mm/memblock.c: cast constant ULLONG_MAX to phys_addr_t


commit e2a5dca753d1cdc3212519023ed8a13e13f5495b
Author: Borislav Petkov <bp@...e.de>
Date:   Thu Nov 23 10:19:51 2017 +0100

    x86/umip: Fix insn_get_code_seg_params()'s return value


commit dae1a432ab1fe79ae53129ededeaece35a2dc14d
Author: Nick Desaulniers <nick.desaulniers@...il.com>
Date:   Sat Jun 24 22:50:12 2017 -0700

    Input: mousedev - fix implicit conversion warning


commit d1600401faad4bc186bfdb291d8af644465e20bd
Author: Matthias Kaehlcke <mka@...omium.org>
Date:   Fri Mar 31 18:00:04 2017 -0700

    ALSA: hda/ca0132: Limit values for chip addresses to 32-bit


commit a45463cbf3f9dcdae683033c256f50bded513d6a
Author: Arnd Bergmann <arnd@...db.de>
Date:   Wed Feb 1 18:01:17 2017 +0100

    workqueue: avoid clang warning


Thanks

Matthias

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ