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]
Message-ID: <20190311135004.GA11528@archlinux-ryzen>
Date:   Mon, 11 Mar 2019 06:50:04 -0700
From:   Nathan Chancellor <natechancellor@...il.com>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Jonathan Cameron <jic23@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Hartmut Knaack <knaack.h@....de>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        linux-iio@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
        clang-built-linux@...glegroups.com
Subject: Re: [PATCH] iio: common: ssp_sensors: Initialize calculated_time in
 ssp_common_process_data

On Mon, Mar 11, 2019 at 12:10:18PM +0100, Arnd Bergmann wrote:
> On Sun, Mar 10, 2019 at 10:37 AM Jonathan Cameron <jic23@...nel.org> wrote:
> > On Thu, 7 Mar 2019 16:35:26 -0800 Nick Desaulniers <ndesaulniers@...gle.com> wrote:
> > > On Thu, Mar 7, 2019 at 1:46 PM Nathan Chancellor <natechancellor@...il.com> wrote:
> > > >
> > > > When building with -Wsometimes-uninitialized, Clang warns:
> > > >
> > > > drivers/iio/common/ssp_sensors/ssp_iio.c:95:6: warning: variable
> > > > 'calculated_time' is used uninitialized whenever 'if' condition is false
> > > > [-Wsometimes-uninitialized]
> > > >
> > > > While it isn't wrong, this will never be a problem because
> > > > iio_push_to_buffers_with_timestamp only uses calculated_time
> > > > on the same condition that it is assigned (when scan_timestamp
> > > > is not zero). While iio_push_to_buffers_with_timestamp is marked
> > > > as inline, Clang does inlining in the optimization stage, which
> > > > happens after the semantic analysis phase (plus inline is merely
> > > > a hint to the compiler).
> > > >
> > > > Fix this by just zero initializing calculated_time.
> > > >
> > > > Link: https://github.com/ClangBuiltLinux/linux/issues/394
> > > > Signed-off-by: Nathan Chancellor <natechancellor@...il.com>
> > >
> > > Knowing that the same invariant holds across function boundaries to
> > > protect access of unitialized values and thus undefined behavior
> > > sounds tricky to diagnose accurately.  Thanks for the patch.
> > > Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
> > Applied to the togreg branch of iio.git and pushed out as testing
> > for the autobuilders to play with it.
> >
> > Note this is going to be a while before it hits mainline but as
> > it is a false (if reasonable!) warning I'm not going to rush
> > it in as a fix.
> 
> I think it's actually a correct warning, it just doesn't trigger
> on gcc because of a known gcc bug.
> 
> I'm not sure however why I don't see the warning with clang-8
> on my local build. Is this something I have to enable
> separately?
> 
>        Arnd

Yes, -Wsometimes-uninitialized is not on by default because
-Wuninitialized is disabled. You can either pass it via KCFLAGS or
modify scripts/Makefile.extrawarn, which is the eventual goal because
Clang can catch things that GCC can't:

https://github.com/ClangBuiltLinux/linux/issues/381

Cheers,
Nathan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ