From: glider@google.com
To: tkjos@google.com, keescook@chromium.org,
gregkh@linuxfoundation.org, arve@android.com, mingo@redhat.com
Cc: dvyukov@google.com, jannh@google.com, devel@driverdev.osuosl.org,
peterz@infradead.org, linux-kernel@vger.kernel.org,
Alexander Potapenko <glider@google.com>
Subject: [PATCH v2 1/3] compiler.h: define __no_initialize
Date: Mon, 2 Mar 2020 14:04:28 +0100 [thread overview]
Message-ID: <20200302130430.201037-1-glider@google.com> (raw)
For CONFIG_INIT_STACK_ALL it's sometimes handy to disable
force-initialization for a local variable, if it is known to be initialized
later on before the first use. This can be done by using the
__no_initialize macro.
__no_initialize should be applied carefully, as future changes to
the code around the local variable may introduce paths on which the
variable remains uninitialized before the use.
Signed-off-by: Alexander Potapenko <glider@google.com>
---
v2:
- changed __do_not_initialize to __no_initialize as requested by Kees
Cook
---
include/linux/compiler-clang.h | 10 ++++++++++
include/linux/compiler_types.h | 4 ++++
2 files changed, 14 insertions(+)
diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index 333a6695a918c..27f774b27b061 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -24,6 +24,16 @@
#define __no_sanitize_address
#endif
+/*
+ * Disable initialization of a local variable when building with
+ * CONFIG_INIT_STACK_ALL.
+ */
+#ifdef CONFIG_INIT_STACK_ALL
+#define __no_initialize __attribute__((uninitialized))
+#else
+#define __no_initialize
+#endif
+
/*
* Not all versions of clang implement the the type-generic versions
* of the builtin overflow checkers. Fortunately, clang implements
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 72393a8c1a6c5..0208699c855af 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -216,6 +216,10 @@ struct ftrace_likely_data {
# define __no_fgcse
#endif
+#ifndef __no_initialize
+#define __no_initialize
+#endif
+
/* Are two types/vars the same type (ignoring qualifiers)? */
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
--
2.25.0.265.gbab2e86ba0-goog
next reply other threads:[~2020-03-02 13:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-02 13:04 glider [this message]
2020-03-02 13:04 ` [PATCH v2 2/3] binder: do not initialize locals passed to copy_from_user() glider
2020-03-02 13:09 ` Joe Perches
2020-03-02 13:25 ` Alexander Potapenko
2020-03-02 13:52 ` Dan Carpenter
2020-03-02 13:58 ` Joe Perches
2020-03-02 18:17 ` Alexander Potapenko
2020-03-02 18:31 ` Jann Horn
2020-03-05 9:03 ` Rasmus Villemoes
2020-03-05 12:45 ` Jann Horn
2020-03-06 2:29 ` Al Viro
2020-03-02 18:50 ` Joe Perches
2020-03-03 9:14 ` Alexander Potapenko
2020-03-03 9:38 ` Dan Carpenter
2020-03-03 13:56 ` Joe Perches
2020-03-03 14:15 ` Dan Carpenter
2020-03-04 18:13 ` Kees Cook
2020-03-05 8:07 ` Dan Carpenter
2020-03-05 8:26 ` Kees Cook
2020-03-05 8:33 ` Alexander Potapenko
2020-03-02 17:38 ` Greg KH
2020-03-02 18:28 ` Alexander Potapenko
2020-03-02 13:04 ` [PATCH v2 3/3] sched/wait: avoid double initialization in ___wait_event() glider
2020-03-02 16:56 ` Todd Kjos
2020-03-02 18:03 ` Alexander Potapenko
2020-03-02 18:39 ` Greg Kroah-Hartman
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=20200302130430.201037-1-glider@google.com \
--to=glider@google.com \
--cc=arve@android.com \
--cc=devel@driverdev.osuosl.org \
--cc=dvyukov@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jannh@google.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tkjos@google.com \
/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