lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20190221114604.GE10737@kroah.com>
Date:   Thu, 21 Feb 2019 12:46:04 +0100
From:   Greg KH <greg@...ah.com>
To:     linux-kernel@...r.kernel.org
Cc:     cai@....pw, stable-commits@...r.kernel.org
Subject: Re: Patch "x86_64: increase stack size for KASAN_EXTRA" has been
 added to the 4.20-stable tree

On Thu, Feb 21, 2019 at 12:43:23AM -0500, Sasha Levin wrote:
> This is a note to let you know that I've just added the patch titled
> 
>     x86_64: increase stack size for KASAN_EXTRA
> 
> to the 4.20-stable tree which can be found at:
>     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> 
> The filename of the patch is:
>      x86_64-increase-stack-size-for-kasan_extra.patch
> and it can be found in the queue-4.20 subdirectory.
> 
> If you, or anyone else, feels it should not be added to the stable tree,
> please let <stable@...r.kernel.org> know about it.
> 
> 
> 
> commit 67fd2fd35761d6bb8dcebe5070960c2f0baaef69
> Author: Qian Cai <cai@....pw>
> Date:   Fri Feb 1 14:20:20 2019 -0800
> 
>     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@....pw>
>     Cc: Thomas Gleixner <tglx@...utronix.de>
>     Cc: Ingo Molnar <mingo@...hat.com>
>     Cc: Borislav Petkov <bp@...en8.de>
>     Cc: "H. Peter Anvin" <hpa@...or.com>
>     Cc: Andrey Ryabinin <aryabinin@...tuozzo.com>
>     Cc: Alexander Potapenko <glider@...gle.com>
>     Cc: Dmitry Vyukov <dvyukov@...gle.com>
>     Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
>     Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
>     Signed-off-by: Sasha Levin <sashal@...nel.org>
> 
> diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
> index 8f657286d599a..0ce558a8150d3 100644
> --- a/arch/x86/include/asm/page_64_types.h
> +++ b/arch/x86/include/asm/page_64_types.h
> @@ -7,7 +7,11 @@
>  #endif
>  
>  #ifdef CONFIG_KASAN
> +#ifdef CONFIG_KASAN_EXTRA
> +#define KASAN_STACK_ORDER 2
> +#else
>  #define KASAN_STACK_ORDER 1
> +#endif
>  #else
>  #define KASAN_STACK_ORDER 0
>  #endif

This looks like it is also relevant for 4.19.y so I have queued it up
there too.

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ