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: <CAGXu5jLMWrb4Dszv5YSyoGt5Lb3S1oE8EnKsTou7=7Nq1rEEVQ@mail.gmail.com>
Date:   Tue, 12 Feb 2019 10:57:05 -0800
From:   Kees Cook <keescook@...omium.org>
To:     Krzysztof Kozlowski <krzk@...nel.org>
Cc:     "Gustavo A. R. Silva" <gustavo@...eddedor.com>,
        Kukjin Kim <kgene@...nel.org>,
        Sylwester Nawrocki <s.nawrocki@...sung.com>,
        Tomasz Figa <tomasz.figa@...il.com>,
        Chanwoo Choi <cw00.choi@...sung.com>,
        Michael Turquette <mturquette@...libre.com>,
        Stephen Boyd <sboyd@...nel.org>,
        linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
        "linux-samsung-soc@...r.kernel.org" 
        <linux-samsung-soc@...r.kernel.org>, linux-clk@...r.kernel.org,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] clk: samsung: s3c2443: Mark expected switch fall-through

On Mon, Feb 11, 2019 at 11:41 PM Krzysztof Kozlowski <krzk@...nel.org> wrote:
>
> On Mon, 11 Feb 2019 at 19:40, Gustavo A. R. Silva
> <gustavo@...eddedor.com> wrote:
> >
> > In preparation to enabling -Wimplicit-fallthrough, mark switch
> > cases where we are expecting to fall through.
> >
> > This patch fixes the following warnings:
> >
> > drivers/clk/samsung/clk-s3c2443.c: In function ‘s3c2443_common_clk_init’:
> > drivers/clk/samsung/clk-s3c2443.c:390:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
> >    samsung_clk_register_alias(ctx, s3c2450_aliases,
> >    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >      ARRAY_SIZE(s3c2450_aliases));
> >      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > drivers/clk/samsung/clk-s3c2443.c:393:2: note: here
> >   case S3C2416:
> >   ^~~~
> >
> > Warning level 3 was used: -Wimplicit-fallthrough=3
> >
> > Notice that, in this particular case,  the code comment is modified
> > in accordance with what GCC is expecting to find.
> >
> > This patch is part of the ongoing efforts to enable
> > -Wimplicit-fallthrough.
>
> I saw this in multiple places already and I think fix is wrong. The
> point is that the code is correct - the fall through is marked
> properly.
>
> It is just the GCC which has to be fixed not the code. You want to
> adjust the code for specific version of GCC and what if GCC changes
> its warning? For example GCC might require "fall through: "... or any
> other syntax. Another point - what about clang's syntax?

-Wimplicit-fallthrough=3 is stricter and maps to -Wextra, hence its
choice. GCC's levels were chosen based on the existing linters, static
analyzers, etc. The patterns are unlikely to change (see the gcc
man-page).

Clang doesn't recognize anything in C mode (hopefully this will be
fixed in the future[1]).

As long as one of the compilers is able to check this, we'll avoid the
bugs associated with this mis-pattern. Gustavo's efforts here have
found kind of a lot of bugs, so I think it's worth a little churn to
add these (and make minor adjustments to existing comments).

[1] https://bugs.llvm.org/show_bug.cgi?id=37135

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ