public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Kbuild: Disable the -Wformat-security gcc flag
@ 2009-02-04 14:28 Floris Kraak
  2009-02-04 22:14 ` Sam Ravnborg
  2009-05-15 10:23 ` Pekka Enberg
  0 siblings, 2 replies; 22+ messages in thread
From: Floris Kraak @ 2009-02-04 14:28 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Alan Cox, Linux Kernel Mailing List, Trivial Patch Monkey

Some distributions have enabled the gcc flag -Wformat-security by default.*
This results in a number of warnings about format arguments to
functions, sometimes in cases where fixing the warning is not likely
to actually fix a bug.
Instead of hand patching a dozens of places (possibly more) that
produce warnings that get ignored anyway we just turn off the flag in
the Makefile.

Note: Regardless of any discussion surrounding the value of this
particular type of warning, having this show up in a few distributions
but not in the
vast majority of them means that this warning won't be seen by most of
the developers who introduce the new warnings in the first place. If
the
kernel decides it cares about format arguments it should do so
globally regardless of distribution. In which case I'd gladly whip up
a patch to do
the reverse thing and turn this thing on by default. However, such a
patch would have to produce a follow up patch(set) which fixes each
individual
warning.

See also:
http://kerneltrap.org/mailarchive/linux-kernel/2008/11/20/4215134

*) The ubuntu manpage for gcc states:

      -Wformat-security
          If -Wformat is specified, also warn about uses of format
functions that represent possible security problems.  At present, this
warns about
          calls to "printf" and "scanf" functions where the format
string is not a string literal and there are no format arguments, as
in "printf
          (foo);".  This may be a security hole if the format string
came from untrusted input and contains %n.  (This is currently a
subset of what
          -Wformat-nonliteral warns about, but in future warnings may
be added to -Wformat-security that are not included in
-Wformat-nonliteral.)

          NOTE: In Ubuntu 8.10 and later versions this option is
enabled by default for C, C++, ObjC, ObjC++.  To disable, use
-Wno-format-security, or
          disable all format warnings with -Wformat=0.  To make format
security warnings fatal, specify -Werror=format-security.

Signed-off-by: Floris Kraak <randakar@gmail.com>
---
diff --git a/Makefile b/Makefile
index 7715b2c..9ee766c 100644
--- a/Makefile
+++ b/Makefile
@@ -346,7 +346,8 @@ KBUILD_CPPFLAGS := -D__KERNEL__

 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common \
-		   -Werror-implicit-function-declaration
+		   -Werror-implicit-function-declaration \
+		   -Wno-format-security
 KBUILD_AFLAGS   := -D__ASSEMBLY__

 # Read KERNELRELEASE from include/config/kernel.release (if it exists)

---
"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."
  -- Ben Franklin

"The course of history shows that as a government grows, liberty
decreases."
  -- Thomas Jefferson

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2009-06-26 22:13 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-04 14:28 [PATCH] Kbuild: Disable the -Wformat-security gcc flag Floris Kraak
2009-02-04 22:14 ` Sam Ravnborg
2009-02-04 22:26   ` Roland Dreier
2009-02-04 23:48     ` Robert Hancock
2009-02-05  6:37       ` Roland Dreier
2009-02-05  8:26         ` Floris Kraak
2009-02-05 10:15           ` Floris Kraak
2009-02-05 10:27             ` Andreas Schwab
2009-02-05 10:50               ` Floris Kraak
2009-02-05 21:52               ` Roland Dreier
2009-02-10 21:11           ` Kyle Moffett
2009-02-10 21:56             ` Floris Kraak
2009-02-10 20:24     ` Pavel Machek
2009-02-10 21:48       ` Floris Kraak
2009-05-15 10:23 ` Pekka Enberg
2009-05-15 13:28   ` Floris Kraak
2009-05-15 20:42     ` Pekka Enberg
2009-05-15 22:09       ` Floris Kraak
2009-06-14 20:50     ` Sam Ravnborg
2009-06-15  5:54       ` Pekka J Enberg
2009-06-15  8:02         ` Floris Kraak
2009-06-26 22:15         ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox