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: <CAKwvOdkOG_fcJLc-2mFUUp9N1CrJ6EcnZjpraHsvfTsmiKX4SQ@mail.gmail.com>
Date:   Fri, 12 Jul 2019 09:48:08 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        clang-built-linux <clang-built-linux@...glegroups.com>,
        Nathan Chancellor <natechancellor@...il.com>
Subject: Re: [PATCH] waitqueue: fix clang -Wuninitialized warnings

On Fri, Jul 12, 2019 at 12:45 AM Arnd Bergmann <arnd@...db.de> wrote:
>
> On Fri, Jul 12, 2019 at 2:49 AM Andrew Morton <akpm@...ux-foundation.org> wrote:
> > On Wed,  3 Jul 2019 10:10:55 +0200 Arnd Bergmann <arnd@...db.de> wrote:
>
> > <scratches head>
> >
> > Surely clang is being extraordinarily dumb here?
> >
> > DECLARE_WAIT_QUEUE_HEAD_ONSTACK() is effectively doing
> >
> >         struct wait_queue_head name = ({ __init_waitqueue_head(&name) ; name; })
> >
> > which is perfectly legitimate!  clang has no business assuming that
> > __init_waitqueue_head() will do any reads from the pointer which it was
> > passed, nor can clang assume that __init_waitqueue_head() leaves any of
> > *name uninitialized.
> >
> > Does it also warn if code does this?
> >
> >         struct wait_queue_head name;
> >         __init_waitqueue_head(&name);
> >         name = name;
> >
> > which is equivalent, isn't it?
>
> No, it does not warn for this.

So I think this is just a bug in Clang, where it's getting tripped up
due to the GNU C statement expression.  See the example I put in this
bug report: https://bugs.llvm.org/show_bug.cgi?id=42604

Clang is warning for this pattern of struct assignment, but not for
non-aggregate (integral) assignment.

(I think that pattern is pretty cool; it makes it more straightforward
to provide macro's that properly construct aggregates in C; in
particular I feel like I've been looking for something like this to
simply the use of __attribute__((__cleanup__)) to do RAII in C and
make smart pointers, fd's, etc.).

Let's fix Clang, drop the kernel workaround, and thanks for the discussion.
-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ