All of lore.kernel.org
 help / color / mirror / Atom feed
From: <gregkh@linuxfoundation.org>
To: arnd@arndb.de, akpm@linux-foundation.org,
	alexander.levin@verizon.com, andreyknvl@google.com,
	aryabinin@virtuozzo.com, dvyukov@google.com, glider@google.com,
	gregkh@linuxfoundation.org, mchehab@kernel.org,
	stable@vger.kernel.org, sudipm.mukherjee@gmail.com,
	torvalds@linux-foundation.org
Cc: <stable@vger.kernel.org>, <stable-commits@vger.kernel.org>
Subject: Patch "kasan: rework Kconfig settings" has been added to the 4.9-stable tree
Date: Fri, 23 Feb 2018 16:42:42 +0100	[thread overview]
Message-ID: <1519400562178137@kroah.com> (raw)
In-Reply-To: <20180219101343.2922561-2-arnd@arndb.de>


This is a note to let you know that I've just added the patch titled

    kasan: rework Kconfig settings

to the 4.9-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:
     kasan-rework-kconfig-settings.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From foo@baz Fri Feb 23 16:40:21 CET 2018
From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 19 Feb 2018 11:13:20 +0100
Subject: kasan: rework Kconfig settings
To: stable@vger.kernel.org
Cc: Greg KH <gregkh@linuxfoundation.org>, linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>, Mauro Carvalho Chehab <mchehab@kernel.org>, Andrey Ryabinin <aryabinin@virtuozzo.com>, Alexander Potapenko <glider@google.com>, Dmitry Vyukov <dvyukov@google.com>, Andrey Konovalov <andreyknvl@google.com>, Andrew Morton <akpm@linux-foundation.org>, Linus Torvalds <torvalds@linux-foundation.org>, Sasha Levin <alexander.levin@verizon.com>, Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Message-ID: <20180219101343.2922561-2-arnd@arndb.de>

From: Arnd Bergmann <arnd@arndb.de>

commit e7c52b84fb18f08ce49b6067ae6285aca79084a8 upstream.

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:2434:1: warning: the frame size of 46176 bytes is larger than 3072 bytes
  drivers/net/wireless/ralink/rt2x00/rt2800lib.c:5650:1: warning: the frame size of 23632 bytes is larger than 3072 bytes
  lib/atomic64_test.c:250:1: warning: the frame size of 11200 bytes is larger than 3072 bytes
  drivers/gpu/drm/i915/gvt/handlers.c:2621:1: warning: the frame size of 9208 bytes is larger than 3072 bytes
  drivers/media/dvb-frontends/stv090x.c:3431:1: warning: the frame size of 6816 bytes is larger than 3072 bytes
  fs/fscache/stats.c:287:1: warning: the frame size of 6536 bytes is larger than 3072 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.

All patches to get the frame size below 2048 bytes with CONFIG_KASAN=y
and CONFIG_KASAN_EXTRA=n have been merged by maintainers now, 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 3f181b4d8652 ("lib/Kconfig.debug: disable
-Wframe-larger-than warnings with KASAN=y").  Two patches in linux-next
should be merged first to avoid introducing warnings in an allmodconfig
build:
  3cd890dbe2a4 ("media: dvb-frontends: fix i2c access helpers for KASAN")
  16c3ada89cff ("media: r820t: fix r820t_write_reg for KASAN")

Do we really need to backport this?

I think we do: without this patch, enabling KASAN will lead to
unavoidable kernel stack overflow in certain device drivers when built
with gcc-7 or higher on linux-4.10+ or any version that contains a
backport of commit c5caf21ab0cf8.  Most people are probably still on
older compilers, but it will get worse over time as they upgrade their
distros.

The warnings we get on kernels older than this should all be for code
that uses dangerously large stack frames, though most of them do not
cause an actual stack overflow by themselves.The asan-stack option was
added in linux-4.0, and commit 3f181b4d8652 ("lib/Kconfig.debug:
disable -Wframe-larger-than warnings with KASAN=y") effectively turned
off the warning for allmodconfig kernels, so I would like to see this
fix backported to any kernels later than 4.0.

I have done dozens of fixes for individual functions with stack frames
larger than 2048 bytes with asan-stack, and I plan to make sure that
all those fixes make it into the stable kernels as well (most are
already there).

Part of the complication here is that asan-stack (from 4.0) was
originally assumed to always require much larger stacks, but that
turned out to be a combination of multiple gcc bugs that we have now
worked around and fixed, but sanitize-address-use-after-scope (from
v4.10) has a much higher inherent stack usage and also suffers from at
least three other problems that we have analyzed but not yet fixed
upstream, each of them makes the stack usage more severe than it should
be.

Link: http://lkml.kernel.org/r/20171221134744.2295529-1-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[arnd: rebase to v4.9; only re-enable warning]
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 lib/Kconfig.debug |    1 -
 1 file changed, 1 deletion(-)

--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -197,7 +197,6 @@ config ENABLE_MUST_CHECK
 config FRAME_WARN
 	int "Warn for stack frames larger than (needs gcc 4.4)"
 	range 0 8192
-	default 0 if KASAN
 	default 2048 if GCC_PLUGIN_LATENT_ENTROPY
 	default 1024 if !64BIT
 	default 2048 if 64BIT


Patches currently in stable-queue which might be from arnd@arndb.de are

queue-4.9/kasan-rework-kconfig-settings.patch
queue-4.9/tw5864-use-dev_warn-instead-of-warn-to-shut-up-warning.patch
queue-4.9/perf-x86-shut-up-false-positive-wmaybe-uninitialized-warning.patch
queue-4.9/go7007-add-media_camera_support-dependency.patch
queue-4.9/scsi-advansys-fix-build-warning-for-pci-n.patch
queue-4.9/video-fbdev-via-remove-possibly-unused-variables.patch
queue-4.9/drm-exynos-mark-pm-functions-as-__maybe_unused.patch
queue-4.9/binfmt_elf-compat-avoid-unused-function-warning.patch
queue-4.9/idle-i7300-add-pci-dependency.patch
queue-4.9/cw1200-fix-bogus-maybe-uninitialized-warning.patch
queue-4.9/x86-build-silence-the-build-with-make-s.patch
queue-4.9/gpio-xgene-mark-pm-functions-as-__maybe_unused.patch
queue-4.9/kvm-add-x86_local_apic-dependency.patch
queue-4.9/reiserfs-avoid-a-wmaybe-uninitialized-warning.patch
queue-4.9/scsi-advansys-fix-uninitialized-data-access.patch
queue-4.9/drm-i915-fix-intel_backlight_device_register-declaration.patch
queue-4.9/spi-bcm-qspi-shut-up-warning-about-cfi-header-inclusion.patch
queue-4.9/asoc-ux500-add-module_license-tag.patch
queue-4.9/x86-microcode-amd-change-load_microcode_amd-s-param-to-bool-to-fix-preemptibility-bug.patch
queue-4.9/video-fbdev-mmp-add-module_license.patch
queue-4.9/usb-phy-msm-add-regulator-dependency.patch
queue-4.9/arm64-dts-add-cooling-cells-to-cpu-nodes.patch
queue-4.9/vmxnet3-prevent-building-with-64k-pages.patch
queue-4.9/x86-platform-add-pci-dependency-for-punit_atom_debug.patch
queue-4.9/alsa-hda-ca0132-fix-possible-null-pointer-use.patch
queue-4.9/thermal-fix-intel_soc_dts_iosf_core-dependencies.patch
queue-4.9/arm64-define-bug-instruction-without-config_bug.patch
queue-4.9/arm64-sunxi-always-enable-reset-controller.patch
queue-4.9/tc358743-fix-register-i2c_rd-wr-functions.patch
queue-4.9/security-keys-big_key-requires-config_crypto.patch
queue-4.9/drm-i915-hide-unused-intel_panel_set_backlight-function.patch
queue-4.9/x86-fpu-math-emu-fix-possible-uninitialized-variable-use.patch
queue-4.9/arm-8743-1-bl_switcher-add-module_license-tag.patch
queue-4.9/em28xx-only-use-mt9v011-if-camera-support-is-enabled.patch
queue-4.9/arm64-fix-warning-about-swapper_pg_dir-overflow.patch
queue-4.9/shmem-avoid-maybe-uninitialized-warning.patch
queue-4.9/input-tca8418_keypad-hide-gcc-4.9-wmaybe-uninitialized-warning.patch
queue-4.9/drm-nouveau-hide-gcc-4.9-wmaybe-uninitialized.patch
queue-4.9/x86-add-multiuser-dependency-for-kvm.patch
queue-4.9/isdn-eicon-reduce-stack-size-of-sig_ind-function.patch

  reply	other threads:[~2018-02-23 15:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-19 10:13 [4.9-stable 0/9] patches for 'randconfig' Arnd Bergmann
2018-02-19 10:13 ` [4.9-stable 1/9] kasan: rework Kconfig settings Arnd Bergmann
2018-02-23 15:42   ` gregkh [this message]
2018-02-19 10:13 ` [4.9-stable 2/9] drm/i915: hide unused intel_panel_set_backlight function Arnd Bergmann
2018-02-19 10:13   ` Arnd Bergmann
2018-02-23 15:42   ` Patch "drm/i915: hide unused intel_panel_set_backlight function" has been added to the 4.9-stable tree gregkh
2018-02-19 10:13 ` [4.9-stable 3/9] arm64: sunxi: always enable reset controller Arnd Bergmann
2018-02-19 10:13   ` Arnd Bergmann
2018-02-23 15:42   ` Patch "arm64: sunxi: always enable reset controller" has been added to the 4.9-stable tree gregkh
2018-02-19 10:13 ` [4.9-stable 4/9] binfmt_elf: compat: avoid unused function warning Arnd Bergmann
2018-02-23 15:42   ` Patch "binfmt_elf: compat: avoid unused function warning" has been added to the 4.9-stable tree gregkh
2018-02-19 10:13 ` [4.9-stable 5/9] spi: bcm-qspi: shut up warning about cfi header inclusion Arnd Bergmann
2018-02-23 15:43   ` Patch "spi: bcm-qspi: shut up warning about cfi header inclusion" has been added to the 4.9-stable tree gregkh
2018-02-19 10:13 ` [4.9-stable 6/9] idle: i7300: add PCI dependency Arnd Bergmann
2018-02-23 15:42   ` Patch "idle: i7300: add PCI dependency" has been added to the 4.9-stable tree gregkh
2018-02-19 10:13 ` [4.9-stable 7/9] arm64: fix warning about swapper_pg_dir overflow Arnd Bergmann
2018-02-19 10:13   ` Arnd Bergmann
2018-02-23 15:42   ` Patch "arm64: fix warning about swapper_pg_dir overflow" has been added to the 4.9-stable tree gregkh
2018-02-19 10:13 ` [4.9-stable 9/9] x86/microcode/AMD: Change load_microcode_amd()'s param to bool to fix preemptibility bug Arnd Bergmann
2018-02-23 15:43   ` Patch "x86/microcode/AMD: Change load_microcode_amd()'s param to bool to fix preemptibility bug" has been added to the 4.9-stable tree gregkh
2018-02-23 15:42 ` [4.9-stable 0/9] patches for 'randconfig' Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2018-02-19 10:13 [4.9-stable,8/9] usb: phy: msm add regulator dependency Arnd Bergmann
2018-02-19 10:13 ` [4.9-stable 8/9] " Arnd Bergmann
2018-02-23 15:43 ` Patch "usb: phy: msm add regulator dependency" has been added to the 4.9-stable tree gregkh

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=1519400562178137@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.levin@verizon.com \
    --cc=andreyknvl@google.com \
    --cc=arnd@arndb.de \
    --cc=aryabinin@virtuozzo.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=mchehab@kernel.org \
    --cc=stable-commits@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=sudipm.mukherjee@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /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.