Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1673844
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3 07/11] tty: improve tty_insert_flip_char() fast path |
| Date | 2017-06-23 22:30 +0200 |
| Message-ID | <tVDnl-6P1-55@gated-at.bofh.it> (permalink) |
| References | <tVdVT-7HO-3@gated-at.bofh.it> <tVdVV-7HO-49@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Jun 22, 2017 at 07:13:51PM +0200, Arnd Bergmann wrote:
> kernelci.org reports a crazy stack usage for the VT code when CONFIG_KASAN
> is enabled:
>
> drivers/tty/vt/keyboard.c: In function 'kbd_keycode':
> drivers/tty/vt/keyboard.c:1452:1: error: the frame size of 2240 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
>
> The problem is that tty_insert_flip_char() gets inlined many times into
> kbd_keycode(), and also into other functions, and each copy requires 128
> bytes for stack redzone to check for a possible out-of-bounds access on
> the 'ch' and 'flags' arguments that are passed into
> tty_insert_flip_string_flags as a variable-length string.
>
> This introduces a new __tty_insert_flip_char() function for the slow
> path, which receives the two arguments by value. This completely avoids
> the problem and the stack usage goes back down to around 100 bytes.
>
> Without KASAN, this is also slightly better, as we don't have to
> spill the arguments to the stack but can simply pass 'ch' and 'flag'
> in registers, saving a few bytes in .text for each call site.
>
> This should be backported to linux-4.0 or later, which first introduced
> the stack sanitizer in the kernel.
>
> Cc: stable@vger.kernel.org
> Fixes: c420f167db8c ("kasan: enable stack instrumentation")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> I already submitted this separately to Greg, but he hasn't replied
> yet. I assume that it's fine if Andrew picks it up along with the
> other patches and drops it again in case Greg applies it to linux-next.
I've been traveling in China this week, give me a chance to catch up
please.
And no, I don't like this patch either, I think kasan needs to be fixed
here, not work around it in odd ways in code that is completly
acceptable to "sane" compilers. But give me a week to catch up on my
pending stuff first...
thanks,
greg k-h
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3 00/11] bring back stack frame warning with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-06-22 19:20 +0200
[PATCH v3 07/11] tty: improve tty_insert_flip_char() fast path Arnd Bergmann <arnd@arndb.de> - 2017-06-22 19:20 +0200
Re: [PATCH v3 07/11] tty: improve tty_insert_flip_char() fast path Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-23 22:30 +0200
Re: [PATCH v3 07/11] tty: improve tty_insert_flip_char() fast path Arnd Bergmann <arnd@arndb.de> - 2017-06-26 16:10 +0200
Re: [PATCH v3 07/11] tty: improve tty_insert_flip_char() fast path Arnd Bergmann <arnd@arndb.de> - 2017-06-27 22:50 +0200
[PATCH v3 08/11] brcmsmac: make some local variables 'static const' to reduce stack size Arnd Bergmann <arnd@arndb.de> - 2017-06-22 19:20 +0200
[PATCH v3 04/11] mtd: cfi: reduce stack size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-06-22 19:20 +0200
csiph-web