From: Nick Desaulniers <ndesaulniers@google.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Bill Wendling <morbo@google.com>,
Randy Dunlap <rdunlap@infradead.org>
Cc: Bill Wendling <isanbard@gmail.com>,
Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
Phillip Potter <phil@philpotter.co.uk>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Jan Kara <jack@suse.com>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Nathan Chancellor <nathan@kernel.org>, Tom Rix <trix@redhat.com>,
Ross Philipson <ross.philipson@oracle.com>,
Daniel Kiper <daniel.kiper@oracle.com>,
linux-edac@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Linux Memory Management List <linux-mm@kvack.org>,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
Network Development <netdev@vger.kernel.org>,
alsa-devel@alsa-project.org,
clang-built-linux <llvm@lists.linux.dev>,
Justin Stitt <jstitt007@gmail.com>,
Justin Stitt <justinstitt@google.com>
Subject: Re: [PATCH 00/12] Clang -Wformat warning fixes
Date: Thu, 9 Jun 2022 17:32:46 -0700 [thread overview]
Message-ID: <CAKwvOdmfC3kgGuimbtG8n74f8qJ5+vd3GeHg14oOxkKOfuQfBg@mail.gmail.com> (raw)
In-Reply-To: <20220609152527.4ad7862d4126e276e6f76315@linux-foundation.org>
On Thu, Jun 9, 2022 at 3:25 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Thu, 9 Jun 2022 22:16:19 +0000 Bill Wendling <morbo@google.com> wrote:
>
> > This patch set fixes some clang warnings when -Wformat is enabled.
It looks like this series fixes -Wformat-security, which while being a
member of the -Wformat group, is intentionally disabled in the kernel
and somewhat orthogonal to enabling -Wformat with Clang.
-Wformat is a group flag (like -Wall) that enables multiple other
flags implicitly. Reading through
clang/include/clang/Basic/DiagnosticGroups.td in clang's sources, it
looks like:
1. -Wformat is a group flag.
2. -Wformat-security is a member of the -Wformat group; enabling
-Wformat will enable -Wformat-security.
3. -Wformat itself is a member of -Wmost (never heard of -Wmost, but
w/e). So -Wmost will enable -Wformat will enable -Wformat-security.
4. -Wmost is itself a member of -Wall. -Wall enables -Wmost enables
-Wformat enables -Wformat security.
Looking now at Kbuild:
1. Makefile:523 adds -Wall to KBUILD_CFLAGS.
2. The same assignment expression but on line 526 immediately disables
-Wformat-security via -Wno-format-security.
3. scripts/Makefile.extrawarn disables -Wformat via -Wno-format only
for clang (via guard of CONFIG_CC_IS_CLANG).
We _want_ -Wformat enabled for clang so that developers aren't sending
patches that trigger -Wformat with GCC (if they didn't happen to test
their code with both). It's disabled for clang until we can build the
kernel cleanly with it enabled, which we'd like to do.
I don't think that we need to enable -Wformat-security to build with
-Wformat for clang.
I suspect based on Randy's comment on patch 1/12 that perhaps -Wformat
was _added_ to KBUILD_CFLAGS in scripts/Makefile.extrawarn rather than
-Wno-format being _removed_. The former would re-enable
-Wformat-security due to the grouping logic described above. The
latter is probably closer to our ultimate goal of enabling -Wformat
coverage for clang (or rather not disabling the coverage via
-Wno-format; a double negative).
I'm pretty sure the kernel doesn't support %n in format strings...see
the comment above vsnprintf in lib/vsprintf.c. Are there other
attacks other than %n that -Wformat-security guards against? Maybe
there's some context on the commit that added -Wno-format-security to
the kernel? Regardless, I don't think enabling -Wformat-security is a
blocker for enabling -Wformat (or...disabling -Wno-format...two sides
of the same coin) for clang.
> >
>
> tldr:
>
> - printk(msg);
> + printk("%s", msg);
>
> the only reason to make this change is where `msg' could contain a `%'.
> Generally, it came from userspace. Otherwise these changes are a
> useless consumer of runtime resources.
>
> I think it would be better to quieten clang in some fashion.
--
Thanks,
~Nick Desaulniers
prev parent reply other threads:[~2022-06-10 0:33 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 22:16 Bill Wendling
2022-06-09 22:16 ` [PATCH 01/12] x86/mce: use correct format characters Bill Wendling
2022-06-09 23:14 ` Randy Dunlap
2022-06-09 23:18 ` Bill Wendling
2022-06-09 22:16 ` [PATCH 02/12] x86/CPU/AMD: " Bill Wendling
2022-06-09 22:16 ` [PATCH 03/12] x86/e820: " Bill Wendling
2022-06-09 22:16 ` [PATCH 04/12] blk-cgroup: " Bill Wendling
2022-06-10 8:10 ` Christoph Hellwig
2022-06-09 22:16 ` [PATCH 05/12] fs: quota: " Bill Wendling
2022-06-09 22:16 ` [PATCH 06/12] PNP: " Bill Wendling
2022-06-09 22:16 ` [PATCH 07/12] driver/char: " Bill Wendling
2022-06-10 5:18 ` Greg Kroah-Hartman
2022-06-13 18:40 ` Bill Wendling
2022-06-09 22:16 ` [PATCH 08/12] cdrom: " Bill Wendling
2022-06-12 16:23 ` Phillip Potter
2022-06-13 18:47 ` Bill Wendling
2022-06-09 22:16 ` [PATCH 09/12] ALSA: seq: " Bill Wendling
2022-06-09 22:16 ` [PATCH 10/12] " Bill Wendling
2022-06-09 22:16 ` [PATCH 11/12] ALSA: control: " Bill Wendling
2022-06-09 22:16 ` [PATCH 12/12] netfilter: conntrack: " Bill Wendling
2022-07-11 14:35 ` Pablo Neira Ayuso
2022-06-09 22:25 ` [PATCH 00/12] Clang -Wformat warning fixes Andrew Morton
2022-06-09 22:49 ` Bill Wendling
2022-06-09 23:03 ` Jan Engelhardt
2022-06-09 23:16 ` Bill Wendling
2022-06-10 1:19 ` Andrew Morton
2022-06-10 5:20 ` Greg Kroah-Hartman
2022-06-10 12:44 ` Joe Perches
2022-06-10 8:17 ` David Laight
2022-06-10 8:32 ` Jan Engelhardt
2022-06-10 9:14 ` David Laight
2022-06-10 9:22 ` Jan Engelhardt
2022-06-10 0:32 ` Nick Desaulniers [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKwvOdmfC3kgGuimbtG8n74f8qJ5+vd3GeHg14oOxkKOfuQfBg@mail.gmail.com \
--to=ndesaulniers@google.com \
--cc=akpm@linux-foundation.org \
--cc=alsa-devel@alsa-project.org \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=coreteam@netfilter.org \
--cc=daniel.kiper@oracle.com \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=isanbard@gmail.com \
--cc=jack@suse.com \
--cc=jstitt007@gmail.com \
--cc=justinstitt@google.com \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=llvm@lists.linux.dev \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=perex@perex.cz \
--cc=phil@philpotter.co.uk \
--cc=rafael.j.wysocki@intel.com \
--cc=rdunlap@infradead.org \
--cc=ross.philipson@oracle.com \
--cc=tglx@linutronix.de \
--cc=tiwai@suse.com \
--cc=tony.luck@intel.com \
--cc=trix@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox