All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Michal Marek <mmarek@suse.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: "Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Jiri Pirko" <jiri@resnulli.us>,
	"Arend van Spriel" <arend.vanspriel@broadcom.com>,
	"Kalle Valo" <kvalo@codeaurora.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Alexander Potapenko" <glider@google.com>,
	"Dmitry Vyukov" <dvyukov@google.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
	brcm80211-dev-list.pdl@broadcom.com,
	brcm80211-dev-list@cypress.com, kasan-dev@googlegroups.com,
	linux-kbuild@vger.kernel.org, "Jakub Jelinek" <jakub@gcc.gnu.org>,
	"Martin Liška" <marxin@gcc.gnu.org>
Subject: Re: [PATCH v4 9/9] kasan: rework Kconfig settings
Date: Tue, 26 Sep 2017 22:36:38 +0300	[thread overview]
Message-ID: <aeb9c144-10a6-53c2-89ba-cc7864f254e1@virtuozzo.com> (raw)
In-Reply-To: <20170922212930.620249-10-arnd@arndb.de>

On 09/23/2017 12:29 AM, Arnd Bergmann wrote:
> We get a lot of very large stack frames using gcc-7.0.1 with the default
> -fsanitize-address-use-after-scope --param asan-stack=1 options, which
> can easily cause an overflow of the kernel stack, e.g.
> 
> drivers/gpu/drm/i915/gvt/handlers.c:2407:1: error: the frame size of 31216 bytes is larger than 2048 bytes
> drivers/net/wireless/ralink/rt2x00/rt2800lib.c:5650:1: error: the frame size of 23632 bytes is larger than 2048 bytes
> drivers/scsi/fnic/fnic_trace.c:451:1: error: the frame size of 5152 bytes is larger than 2048 bytes
> fs/btrfs/relocation.c:1202:1: error: the frame size of 4256 bytes is larger than 2048 bytes
> fs/fscache/stats.c:287:1: error: the frame size of 6552 bytes is larger than 2048 bytes
> lib/atomic64_test.c:250:1: error: the frame size of 12616 bytes is larger than 2048 bytes
> mm/vmscan.c:1367:1: error: the frame size of 5080 bytes is larger than 2048 bytes
> net/wireless/nl80211.c:1905:1: error: the frame size of 4232 bytes is larger than 2048 bytes
> 
> To reduce this risk, -fsanitize-address-use-after-scope is now split
> out into a separate CONFIG_KASAN_EXTRA Kconfig option, leading to stack
> frames that are smaller than 2 kilobytes most of the time on x86_64. An
> earlier version of this patch also prevented combining KASAN_EXTRA with
> KASAN_INLINE, but that is no longer necessary with gcc-7.0.1.
> 
> A lot of warnings with KASAN_EXTRA go away if we disable KMEMCHECK,
> as -fsanitize-address-use-after-scope seems to understand the builtin
> memcpy, but adds checking code around an extern memcpy call. I had to work
> around a circular dependency, as DEBUG_SLAB/SLUB depended on !KMEMCHECK,
> while KASAN did it the other way round. Now we handle both the same way
> and make KASAN and KMEMCHECK mutually exclusive.
> 
> All patches to get the frame size below 2048 bytes with CONFIG_KASAN=y
> and CONFIG_KASAN_EXTRA=n have been submitted along with this patch, so
> we can bring back that default now. KASAN_EXTRA=y still causes lots of
> warnings but now defaults to !COMPILE_TEST to disable it in allmodconfig,
> and it remains disabled in all other defconfigs since it is a new option.
> I arbitrarily raise the warning limit for KASAN_EXTRA to 3072 to reduce
> the noise, but an allmodconfig kernel still has around 50 warnings
> on gcc-7.
> 
> I experimented a bit more with smaller stack frames and have another
> follow-up series that reduces the warning limit for 64-bit architectures
> to 1280 bytes (without CONFIG_KASAN).
> 
> With earlier versions of this patch series, I also had patches to
> address the warnings we get with KASAN and/or KASAN_EXTRA, using a
> "noinline_if_stackbloat" annotation. That annotation now got replaced with
> a gcc-8 bugfix (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715)
> and a workaround for older compilers, which means that KASAN_EXTRA is
> now just as bad as before and will lead to an instant stack overflow in
> a few extreme cases.
> 
> This reverts parts of commit commit 3f181b4 ("lib/Kconfig.debug: disable
> -Wframe-larger-than warnings with KASAN=y").
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

      reply	other threads:[~2017-09-26 19:37 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22 21:29 [PATCH v4 0/9] bring back stack frame warning with KASAN Arnd Bergmann
2017-09-22 21:29 ` Arnd Bergmann
2017-09-22 21:29 ` Arnd Bergmann
2017-09-22 21:29 ` Arnd Bergmann
2017-09-22 21:29 ` [PATCH v4 1/9] brcmsmac: make some local variables 'static const' to reduce stack size Arnd Bergmann
2017-09-22 21:29   ` Arnd Bergmann
2017-09-25  4:33   ` Kalle Valo
2017-09-25  4:33     ` Kalle Valo
2017-10-02 13:53   ` [v4, " Kalle Valo
2017-10-02 13:53     ` Kalle Valo
2017-10-02 13:53     ` Kalle Valo
2017-09-22 21:29 ` [PATCH v4 2/9] brcmsmac: split up wlc_phy_workarounds_nphy Arnd Bergmann
2017-09-22 21:29   ` Arnd Bergmann
2017-10-02 13:55   ` [v4,2/9] " Kalle Valo
2017-10-02 13:55     ` Kalle Valo
2017-10-02 13:55     ` Kalle Valo
2017-10-27  7:51   ` Kalle Valo
2017-10-27  7:51     ` Kalle Valo
2017-10-27  7:51     ` Kalle Valo
2017-09-22 21:29 ` [PATCH v4 3/9] brcmsmac: reindent split functions Arnd Bergmann
2017-09-22 21:29   ` Arnd Bergmann
2017-09-22 21:29 ` [PATCH v4 4/9] em28xx: fix em28xx_dvb_init for KASAN Arnd Bergmann
2017-09-22 21:29   ` Arnd Bergmann
2017-09-25 14:41   ` David Laight
2017-09-25 14:41     ` David Laight
2017-09-26  6:32     ` Arnd Bergmann
2017-09-26  6:32       ` Arnd Bergmann
2017-09-26  6:47       ` Arnd Bergmann
2017-09-26  6:47         ` Arnd Bergmann
2017-09-26 16:49         ` Andrey Ryabinin
2017-09-26 16:49           ` Andrey Ryabinin
2017-09-27 13:26           ` Arnd Bergmann
2017-09-27 13:26             ` Arnd Bergmann
2017-09-28 13:09             ` Andrey Ryabinin
2017-09-28 13:09               ` Andrey Ryabinin
2017-09-28 14:30               ` Arnd Bergmann
2017-09-28 14:30                 ` Arnd Bergmann
2017-10-02  8:33                 ` Arnd Bergmann
2017-10-02  8:33                   ` Arnd Bergmann
2017-10-02  8:40                   ` [PATCH] string.h: work around for increased stack usage Arnd Bergmann
2017-10-02  9:02                     ` Arnd Bergmann
2017-10-02 14:07                     ` Andrey Ryabinin
2017-10-03 18:10                     ` kbuild test robot
2017-10-03 18:10                       ` kbuild test robot
2017-09-22 21:29 ` [PATCH v4 5/9] r820t: fix r820t_write_reg for KASAN Arnd Bergmann
2017-09-22 21:29   ` Arnd Bergmann
2017-09-22 21:29 ` [PATCH v4 6/9] dvb-frontends: fix i2c access helpers " Arnd Bergmann
2017-09-22 21:29   ` Arnd Bergmann
2017-09-22 21:29 ` [PATCH v4 7/9] rocker: fix rocker_tlv_put_* functions " Arnd Bergmann
2017-09-22 21:29   ` Arnd Bergmann
2017-09-26  3:19   ` David Miller
2017-09-22 21:29 ` [PATCH v4 8/9] netlink: fix nla_put_{u8,u16,u32} " Arnd Bergmann
2017-09-22 21:29   ` Arnd Bergmann
2017-09-26  3:19   ` David Miller
2017-09-22 21:29 ` [PATCH v4 9/9] kasan: rework Kconfig settings Arnd Bergmann
2017-09-26 19:36   ` Andrey Ryabinin [this message]

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=aeb9c144-10a6-53c2-89ba-cc7864f254e1@virtuozzo.com \
    --to=aryabinin@virtuozzo.com \
    --cc=akpm@linux-foundation.org \
    --cc=arend.vanspriel@broadcom.com \
    --cc=arnd@arndb.de \
    --cc=brcm80211-dev-list.pdl@broadcom.com \
    --cc=brcm80211-dev-list@cypress.com \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=geert@linux-m68k.org \
    --cc=glider@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jakub@gcc.gnu.org \
    --cc=jiri@resnulli.us \
    --cc=kasan-dev@googlegroups.com \
    --cc=keescook@chromium.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=marxin@gcc.gnu.org \
    --cc=mchehab@kernel.org \
    --cc=mmarek@suse.com \
    --cc=netdev@vger.kernel.org \
    --cc=yamada.masahiro@socionext.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.