All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v12 0/6] Introduce the STACKLEAK feature and a test for it
@ 2018-05-16 16:28 Alexander Popov
  2018-05-16 16:28 ` [PATCH v12 1/6] gcc-plugins: Clean up the cgraph_create_edge* macros Alexander Popov
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Alexander Popov @ 2018-05-16 16:28 UTC (permalink / raw)
  To: kernel-hardening, Kees Cook, PaX Team, Brad Spengler,
	Ingo Molnar, Andy Lutomirski, Tycho Andersen, Laura Abbott,
	Mark Rutland, Ard Biesheuvel, Borislav Petkov, Richard Sandiford,
	Thomas Gleixner, H . Peter Anvin, Peter Zijlstra,
	Dmitry V . Levin, Emese Revfy, Jonathan Corbet, Andrey Ryabinin,
	Kirill A . Shutemov, Thomas Garnier, Andrew Morton,
	Alexei Starovoitov, Josef Bacik, Masami Hiramatsu,
	Nicholas Piggin, Al Viro, David S . Miller, Ding Tianhong,
	David Woodhouse, Josh Poimboeuf, Steven Rostedt,
	Dominik Brodowski, Juergen Gross, Linus Torvalds,
	Greg Kroah-Hartman, Dan Williams, Dave Hansen, Mathias Krause,
	Vikas Shivappa, Kyle Huey, Dmitry Safonov, Will Deacon,
	Arnd Bergmann, Florian Weimer, Boris Lukashev, Andrey Konovalov,
	x86, linux-kernel, alex.popov

This is the 12th version of the patch series introducing STACKLEAK to the
mainline kernel for x86. Some code is made common for easier porting to
arm64 (will be done by Laura Abbott).

Motivation
==========

STACKLEAK (initially developed by PaX Team):

 1. reduces the information that can be revealed through kernel stack leak bugs.
    The idea of erasing the thread stack at the end of syscalls is similar to
    CONFIG_PAGE_POISONING and memzero_explicit() in kernel crypto, which all
    comply with FDP_RIP.2 (Full Residual Information Protection) of the
    Common Criteria standard.

 2. blocks some uninitialized stack variable attacks (e.g. CVE-2017-17712,
    CVE-2010-2963). That kind of bugs should be killed by improving C compilers
    in future, which might take a long time.

 3. blocks stack depth overflow caused by alloca (aka Stack Clash attack).
    That is orthogonal to the mainline kernel VLA cleanup and protects
    un-upstreamed code.

Performance impact
==================

Hardware: Intel Core i7-4770, 16 GB RAM

Test #1: building the Linux kernel on a single core
	0.91% slowdown

Test #2: hackbench -s 4096 -l 2000 -g 15 -f 25 -P
	4.2% slowdown

So the STACKLEAK description in Kconfig includes:
"The tradeoff is the performance impact: on a single CPU system kernel
compilation sees a 1% slowdown, other systems and workloads may vary and you are
advised to test this feature on your expected workload before deploying it".

Changes in v12
==============

1. Some code is made common for easier porting to other platforms.
    Also introduced lowest_stack structure according to Kees' feedback.

2. Changes according to the feedback from Mark Rutland (kudos!):
    - improved stack depth overflow detection and reporting in check_alloca();
    - disabled KCOV instrumentation for erase_kstack() and track_stack();
    - added comments with assumptions about the compiler behaviour in
       erase_kstack().

3. Added a new STACKLEAK_RECURSION_WITH_ALLOCA test.

4. Included Laura's patch for the RTL traversal in the STACKLEAK gcc plugin.

5. Added missing SPDX-License-Identifiers.

Previous version: http://www.openwall.com/lists/kernel-hardening/2018/04/06/2


Alexander Popov (6):
  gcc-plugins: Clean up the cgraph_create_edge* macros
  x86/entry: Add STACKLEAK erasing the kernel stack at the end of
    syscalls
  gcc-plugins: Add STACKLEAK plugin for tracking the kernel stack
  lkdtm: Add a test for STACKLEAK
  fs/proc: Show STACKLEAK metrics in the /proc file system
  doc: self-protection: Add information about STACKLEAK feature

 Documentation/security/self-protection.rst |  23 +-
 Documentation/x86/x86_64/mm.txt            |   2 +
 arch/Kconfig                               |  53 ++++
 arch/x86/Kconfig                           |   1 +
 arch/x86/entry/calling.h                   |  14 +
 arch/x86/entry/entry_32.S                  |   7 +
 arch/x86/entry/entry_64.S                  |   3 +
 arch/x86/entry/entry_64_compat.S           |   5 +
 arch/x86/include/asm/processor.h           |   3 +
 arch/x86/kernel/dumpstack.c                |  31 ++
 arch/x86/kernel/process_32.c               |   8 +
 arch/x86/kernel/process_64.c               |   8 +
 drivers/misc/lkdtm/Makefile                |   2 +
 drivers/misc/lkdtm/core.c                  |   3 +
 drivers/misc/lkdtm/lkdtm.h                 |   5 +
 drivers/misc/lkdtm/stackleak.c             | 147 +++++++++
 fs/proc/base.c                             |  18 ++
 include/linux/stackleak.h                  |  22 ++
 kernel/Makefile                            |   4 +
 kernel/stackleak.c                         | 106 +++++++
 scripts/Makefile.gcc-plugins               |   3 +
 scripts/gcc-plugins/gcc-common.h           |  26 +-
 scripts/gcc-plugins/stackleak_plugin.c     | 474 +++++++++++++++++++++++++++++
 23 files changed, 949 insertions(+), 19 deletions(-)
 create mode 100644 drivers/misc/lkdtm/stackleak.c
 create mode 100644 include/linux/stackleak.h
 create mode 100644 kernel/stackleak.c
 create mode 100644 scripts/gcc-plugins/stackleak_plugin.c

-- 
2.7.4

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-05-24 13:05 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-16 16:28 [PATCH v12 0/6] Introduce the STACKLEAK feature and a test for it Alexander Popov
2018-05-16 16:28 ` [PATCH v12 1/6] gcc-plugins: Clean up the cgraph_create_edge* macros Alexander Popov
2018-05-16 16:28 ` [PATCH v12 2/6] x86/entry: Add STACKLEAK erasing the kernel stack at the end of syscalls Alexander Popov
2018-05-18  6:53   ` Ingo Molnar
2018-05-18 21:12     ` Alexander Popov
2018-05-22 10:58     ` Alexander Popov
2018-05-22 17:20       ` Kees Cook
2018-05-22 21:00         ` Alexander Popov
2018-05-22 21:19           ` Kees Cook
2018-05-24 13:05     ` Alexander Popov
2018-05-16 16:28 ` [PATCH v12 3/6] gcc-plugins: Add STACKLEAK plugin for tracking the kernel stack Alexander Popov
2018-05-16 16:28 ` [PATCH v12 4/6] lkdtm: Add a test for STACKLEAK Alexander Popov
2018-05-16 16:28 ` [PATCH v12 5/6] fs/proc: Show STACKLEAK metrics in the /proc file system Alexander Popov
2018-05-16 16:28 ` [PATCH v12 6/6] doc: self-protection: Add information about STACKLEAK feature Alexander Popov
2018-05-16 23:32 ` [PATCH v12 0/6] Introduce the STACKLEAK feature and a test for it Kees Cook
2018-05-18  6:54   ` Ingo Molnar
2018-05-18 18:10     ` Kees Cook

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.