android_kernel_oneplus_msm8998/arch
Qian Cai d4cf6d934f x86_64: increase stack size for KASAN_EXTRA
[ Upstream commit a8e911d13540487942d53137c156bd7707f66e5d ]

If the kernel is configured with KASAN_EXTRA, the stack size is
increasted significantly because this option sets "-fstack-reuse" to
"none" in GCC [1].  As a result, it triggers stack overrun quite often
with 32k stack size compiled using GCC 8.  For example, this reproducer

  https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/madvise/madvise06.c

triggers a "corrupted stack end detected inside scheduler" very reliably
with CONFIG_SCHED_STACK_END_CHECK enabled.

There are just too many functions that could have a large stack with
KASAN_EXTRA due to large local variables that have been called over and
over again without being able to reuse the stacks.  Some noticiable ones
are

  size
  7648 shrink_page_list
  3584 xfs_rmap_convert
  3312 migrate_page_move_mapping
  3312 dev_ethtool
  3200 migrate_misplaced_transhuge_page
  3168 copy_process

There are other 49 functions are over 2k in size while compiling kernel
with "-Wframe-larger-than=" even with a related minimal config on this
machine.  Hence, it is too much work to change Makefiles for each object
to compile without "-fsanitize-address-use-after-scope" individually.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715#c23

Although there is a patch in GCC 9 to help the situation, GCC 9 probably
won't be released in a few months and then it probably take another
6-month to 1-year for all major distros to include it as a default.
Hence, the stack usage with KASAN_EXTRA can be revisited again in 2020
when GCC 9 is everywhere.  Until then, this patch will help users avoid
stack overrun.

This has already been fixed for arm64 for the same reason via
6e8830674ea ("arm64: kasan: Increase stack size for KASAN_EXTRA").

Link: http://lkml.kernel.org/r/20190109215209.2903-1-cai@lca.pw
Signed-off-by: Qian Cai <cai@lca.pw>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-03-23 08:44:26 +01:00
..
alpha alpha: Fix Eiger NR_IRQS to 128 2019-02-20 10:13:22 +01:00
arc ARC: fix __ffs return value to avoid build warnings 2019-03-23 08:44:19 +01:00
arm KVM: arm/arm64: Fix MMIO emulation data handling 2019-03-23 08:44:20 +01:00
arm64 arm64: ftrace: don't adjust the LR value 2019-02-20 10:13:07 +01:00
avr32
blackfin
c6x
cris mm: replace get_user_pages() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
frv
h8300
hexagon hexagon: modify ffs() and fls() to return int 2018-10-10 08:52:12 +02:00
ia64 mm: replace get_user_pages() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
m32r
m68k m68k: fix "bad page state" oops on ColdFire boot 2018-08-24 13:26:57 +02:00
metag
microblaze microblaze: Fix simpleImage format generation 2018-08-06 16:24:39 +02:00
mips MIPS: irq: Allocate accurate order pages for irq stack 2019-03-23 08:44:23 +01:00
mn10300
nios2
openrisc kthread: fix boot hang (regression) on MIPS/OpenRISC 2018-09-19 22:48:55 +02:00
parisc parisc: Fix map_pages() to not overwrite existing pte entries 2018-11-21 09:27:30 +01:00
powerpc powerpc: Always initialize input array when calling epapr_hypercall() 2019-03-23 08:44:21 +01:00
s390 s390/smp: Fix calling smp_call_ipl_cpu() from ipl CPU 2019-02-06 19:43:05 +01:00
score
sh mm: replace get_user_pages_unlocked() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
sparc mm: replace get_user_pages_unlocked() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
tile
um um: Avoid marking pages with "changed protection" 2019-02-20 10:13:13 +01:00
unicore32
x86 x86_64: increase stack size for KASAN_EXTRA 2019-03-23 08:44:26 +01:00
xtensa xtensa: SMP: limit number of possible CPUs by NR_CPUS 2019-03-23 08:44:25 +01:00
.gitignore
Kconfig