android_kernel_xiaomi_sm7250/init
glider@google.com ef771d8487 UPSTREAM: security: allow using Clang's zero initialization for stack variables
Upstream commit f0fe00d4972a8cd4b98cc2c29758615e4d51cdfe.

In addition to -ftrivial-auto-var-init=pattern (used by
CONFIG_INIT_STACK_ALL now) Clang also supports zero initialization for
locals enabled by -ftrivial-auto-var-init=zero. The future of this flag
is still being debated (see https://bugs.llvm.org/show_bug.cgi?id=45497).
Right now it is guarded by another flag,
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang,
which means it may not be supported by future Clang releases. Another
possible resolution is that -ftrivial-auto-var-init=zero will persist
(as certain users have already started depending on it), but the name
of the guard flag will change.

In the meantime, zero initialization has proven itself as a good
production mitigation measure against uninitialized locals. Unlike pattern
initialization, which has a higher chance of triggering existing bugs,
zero initialization provides safe defaults for strings, pointers, indexes,
and sizes. On the other hand, pattern initialization remains safer for
return values. Chrome OS and Android are moving to using zero
initialization for production builds.

Performance-wise, the difference between pattern and zero initialization
is usually negligible, although the generated code for zero
initialization is more compact.

This patch renames CONFIG_INIT_STACK_ALL to CONFIG_INIT_STACK_ALL_PATTERN
and introduces another config option, CONFIG_INIT_STACK_ALL_ZERO, that
enables zero initialization for locals if the corresponding flags are
supported by Clang.

Cc: Kees Cook <keescook@chromium.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Alexander Potapenko <glider@google.com>
Link: https://lore.kernel.org/r/20200616083435.223038-1-glider@google.com
Reviewed-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Change-Id: Ifa2711b14ada169fe7c22d07a41e26195ffd8ea2
2020-09-02 18:53:22 +02:00
..
calibrate.c
do_mounts_initrd.c init/: remove ineffective sparse disabling 2018-08-22 10:52:49 -07:00
do_mounts_md.c init/: remove ineffective sparse disabling 2018-08-22 10:52:49 -07:00
do_mounts_rd.c init/: remove ineffective sparse disabling 2018-08-22 10:52:49 -07:00
do_mounts.c init/: remove ineffective sparse disabling 2018-08-22 10:52:49 -07:00
do_mounts.h
init_task.c ANDROID: GKI: cpuset: add field for task affinity for cpusets 2020-04-01 15:20:11 -07:00
initramfs.c initramfs: don't free a non-existent initrd 2019-10-01 08:26:09 +02:00
Kconfig Stop the ad-hoc games with -Wno-maybe-initialized 2020-05-20 08:18:45 +02:00
Kconfig.gki ANDROID: GKI: Enable GENERIC_IRQ_CHIP 2020-04-27 23:06:23 +00:00
main.c UPSTREAM: security: allow using Clang's zero initialization for stack variables 2020-09-02 18:53:22 +02:00
Makefile BACKPORT: FROMGIT: kbuild: mkcompile_h: Include $LD version in /proc/version 2020-04-09 15:16:12 +00:00
noinitramfs.c
version.c ANDROID: GKI: Add special linux_banner_ptr for modules 2020-04-22 11:03:17 -07:00