linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Patrick McLean <chutzpah@gentoo.org>,
	"Maciej S. Szmigiero" <mail@maciej.szmigiero.name>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3] kconfig.h: Include compiler types to avoid missed struct attributes
Date: Thu, 22 Feb 2018 09:41:40 -0800	[thread overview]
Message-ID: <20180222174140.GA3154@beast> (raw)

The header files for some structures could get included in such a way
that struct attributes (specifically __randomize_layout from path.h) would
be parsed as variable names instead of attributes. This could lead to
some instances of a structure being unrandomized, causing nasty GPFs, etc.

This patch makes sure the compiler_types.h header is included in
kconfig.h so that we've always got types and struct attributes defined,
since kconfig.h is included from the compiler command line.

Reported-by: Patrick McLean <chutzpah@gentoo.org>
Root-caused-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Tested-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Fixes: 3859a271a003 ("randstruct: Mark various structs for randomization")
Signed-off-by: Kees Cook <keescook@chromium.org>
---
Updated to include Tested-by. Linus, this looks ready to go. I'll send
-stable patches that just fix up path.h.
---
 include/linux/kconfig.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index fec5076eda91..c5fd4ee776ba 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -64,4 +64,7 @@
  */
 #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option))
 
+/* Make sure we always have all types and struct attributes defined. */
+#include <linux/compiler_types.h>
+
 #endif /* __LINUX_KCONFIG_H */
-- 
2.7.4


-- 
Kees Cook
Pixel Security

             reply	other threads:[~2018-02-22 17:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-22 17:41 Kees Cook [this message]
2018-02-22 18:04 ` [PATCH v3] kconfig.h: Include compiler types to avoid missed struct attributes Linus Torvalds
2018-02-22 19:57   ` Kees Cook
2018-02-22 20:17     ` Linus Torvalds
2018-02-22 21:07   ` Rasmus Villemoes
2018-02-22 21:22     ` Kees Cook
2018-02-22 21:23     ` Linus Torvalds
2018-02-22 21:54       ` Linus Torvalds
2018-02-22 21:34     ` Rasmus Villemoes
2018-02-22 21:56       ` Linus Torvalds
2018-02-28 19:17         ` [PATCH 1/3] fixdep: remove stale references to uml-config.h Rasmus Villemoes
2018-02-28 19:17           ` [PATCH 2/3] fixdep: remove some false CONFIG_ matches Rasmus Villemoes
2018-02-28 19:17           ` [PATCH 3/3] fixdep: do not ignore kconfig.h Rasmus Villemoes
2018-03-05  4:52             ` Masahiro Yamada
2018-03-05  8:15               ` Rasmus Villemoes
2018-03-05  9:38                 ` Masahiro Yamada
2018-03-05 14:49             ` Masahiro Yamada

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=20180222174140.GA3154@beast \
    --to=keescook@chromium.org \
    --cc=chutzpah@gentoo.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mail@maciej.szmigiero.name \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).