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] [day] [month] [year] [list]
Date:   Tue, 13 Mar 2018 21:01:21 +0100
From:   Luc Van Oostenryck <luc.vanoostenryck@...il.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Dmitry Vyukov <dvyukov@...gle.com>, linux-sparse@...r.kernel.org,
        Christopher Li <sparse@...isli.org>,
        kbuild test robot <fengguang.wu@...el.com>,
        kbuild-all@...org, LKML <linux-kernel@...r.kernel.org>,
        tipbuild@...or.com, Ingo Molnar <mingo@...nel.org>
Subject: Re: [tip:locking/core 9/11]
 include/asm-generic/atomic-instrumented.h:288:24: sparse: cast truncates
 bits from constant value (100 becomes 0)

On Tue, Mar 13, 2018 at 07:08:06PM +0100, Peter Zijlstra wrote:
> On Tue, Mar 13, 2018 at 07:00:17PM +0100, Luc Van Oostenryck wrote:
> > The issue here is that sparse has a whole class of warnings that are
> > given very early (here at expansion of constant expressions), before
> > eliminating code from branches that are never taken (which, surprise,
> > need itself to have constant expressions already expanded).
> > 
> > It's often annoying like the case here.
> > OTOH, I don't think it's always a bad thing. Sometimes we want to
> > have warnings even from code we know will not be executed (in this
> > config but maybe it will in another one).
> 
> Is that really a valid concern with all the automated randconfig
> building going on today?

I don't think so, for the kernel at least. For other uses it may.
But don't take me wrongly: I don't want to defend those warnings here,
I just want to say that the situation is not totally black & white.


One easy-short-term solution that wouldn't make things ugly would be
to use a mask instead of a cast:

	 static __always_inline unsigned long
	 cmpxchg_size(volatile void *ptr, unsigned long old, unsigned long new, int size)
	 {
	        switch (size) {
	        case 1:
	-               return arch_cmpxchg((u8 *)ptr, (u8)old, (u8)new);
	+               return arch_cmpxchg((u8 *)ptr, old & 0xff, new & 0xff);
	        case 2:
	-               return arch_cmpxchg((u16 *)ptr, (u16)old, (u16)new);
	+               return arch_cmpxchg((u16 *)ptr, old & 0xffff, new & 0xffff);


-- Luc

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ