All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v11 0/6] Introduce the STACKLEAK feature and a test for it
@ 2018-04-06 14:22 Alexander Popov
  2018-04-06 14:22 ` [PATCH v11 1/6] gcc-plugins: Clean up the cgraph_create_edge* macros Alexander Popov
                   ` (7 more replies)
  0 siblings, 8 replies; 76+ messages in thread
From: Alexander Popov @ 2018-04-06 14:22 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, x86, linux-kernel,
	alex.popov

This is the 11th version of the patch series introducing STACKLEAK to the
mainline kernel. The 9th version raised a fervent discussion[0].
The assembly code introduced by that version irritated the reviewers.

I've found the way to bypass the obstacles[1] of the C implementation.
So I dare come again. Let me ask you to look at this code without
preconception.

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".

Links
=====

[0] http://www.openwall.com/lists/kernel-hardening/2018/03/03/7
[1] http://www.openwall.com/lists/kernel-hardening/2018/03/21/4


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/Makefile                    |   3 +
 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/entry/erase.c                     |  58 ++++
 arch/x86/include/asm/processor.h           |   7 +
 arch/x86/kernel/dumpstack.c                |  19 ++
 arch/x86/kernel/process_32.c               |   8 +
 arch/x86/kernel/process_64.c               |   8 +
 drivers/misc/Makefile                      |   3 +
 drivers/misc/lkdtm.h                       |   4 +
 drivers/misc/lkdtm_core.c                  |   2 +
 drivers/misc/lkdtm_stackleak.c             | 141 +++++++++
 fs/proc/base.c                             |  18 ++
 include/linux/compiler.h                   |   4 +
 mm/util.c                                  |  33 ++
 scripts/Makefile.gcc-plugins               |   3 +
 scripts/gcc-plugins/gcc-common.h           |  26 +-
 scripts/gcc-plugins/stackleak_plugin.c     | 470 +++++++++++++++++++++++++++++
 24 files changed, 896 insertions(+), 19 deletions(-)
 create mode 100644 arch/x86/entry/erase.c
 create mode 100644 drivers/misc/lkdtm_stackleak.c
 create mode 100644 scripts/gcc-plugins/stackleak_plugin.c

-- 
2.7.4

^ permalink raw reply	[flat|nested] 76+ messages in thread
* [PATCH v14 0/6] Introduce the STACKLEAK feature and a test for it
@ 2018-07-11 20:36 Alexander Popov
  2018-07-18 21:10   ` Laura Abbott
  0 siblings, 1 reply; 76+ messages in thread
From: Alexander Popov @ 2018-07-11 20:36 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 14th version of the patch series introducing STACKLEAK
to the mainline kernel for x86. This version comes with style changes
according to the feedback from Ingo Molnar and includes Laura Abbott's
modifications of scripts/Makefile.gcc-plugins.

Previous version discussion:
  http://www.openwall.com/lists/kernel-hardening/2018/06/22/8

arm64 support will come in a separate patch from 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".


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/kernel/dumpstack.c                |  31 ++
 drivers/misc/lkdtm/Makefile                |   2 +
 drivers/misc/lkdtm/core.c                  |   3 +
 drivers/misc/lkdtm/lkdtm.h                 |   5 +
 drivers/misc/lkdtm/stackleak.c             | 146 +++++++++
 fs/proc/base.c                             |  18 ++
 include/linux/sched.h                      |   5 +
 include/linux/stackleak.h                  |  26 ++
 kernel/Makefile                            |   4 +
 kernel/fork.c                              |   3 +
 kernel/stackleak.c                         |  94 ++++++
 scripts/Makefile.gcc-plugins               |   8 +-
 scripts/gcc-plugins/gcc-common.h           |  26 +-
 scripts/gcc-plugins/stackleak_plugin.c     | 480 +++++++++++++++++++++++++++++
 22 files changed, 939 insertions(+), 20 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] 76+ messages in thread
* Re: [PATCH RFC v8 0/6] Introduce the STACKLEAK feature and a test for it
@ 2018-02-20 23:33 Laura Abbott
  2018-02-21  1:13   ` Laura Abbott
  0 siblings, 1 reply; 76+ messages in thread
From: Laura Abbott @ 2018-02-20 23:33 UTC (permalink / raw)
  To: Kees Cook, Alexander Popov, Thomas Gleixner, Andy Lutomirski
  Cc: Kernel Hardening, PaX Team, Brad Spengler, Ingo Molnar,
	Tycho Andersen, Mark Rutland, Ard Biesheuvel, Borislav Petkov,
	H . Peter Anvin, Peter Zijlstra, Dmitry V . Levin, X86 ML,
	Mohamed Ghannam

On 02/20/2018 03:17 PM, Kees Cook wrote:
> On Tue, Feb 20, 2018 at 2:29 AM, Alexander Popov <alex.popov@linux.com> wrote:
>> On 16.02.2018 21:10, Alexander Popov wrote:
>>> This is the 8th version of the patch series introducing STACKLEAK to the
>>> mainline kernel. I've made some minor improvements while waiting for the
>>> next review by x86 maintainers.
> 
> If we can borrow some of luto or tglx's time, I think that'd be best:
> they've been looking at the entry code a lot lately. :) Regardless, I
> think the addition to the entry code is clean (especially now that the
> fast path is gone *sob*). :P
> 
>>> STACKLEAK is a security feature developed by Grsecurity/PaX (kudos to them),
>>> which:
>>>   - reduces the information that can be revealed through kernel stack leak bugs;
>>>   - blocks some uninitialized stack variable attacks (e.g. CVE-2010-2963);
>>>   - introduces some runtime checks for kernel stack overflow detection.
> 
> I've added this series to my kernel.org trees, which means 0-day will
> start grinding on it too now:
> https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
> kspp/gcc-plugin/stackleak
> 
> The LKDTM tests look great and check out for me. I think the code is
> clear, so I'd like to get it into -next, but I want to be sure I'm not
> stepping on x86 toes first.
> 
> Laura, how does arm64 look for this? Would it be possible to add it to
> this series (at least on kernel.org for build/run testing)?
> 

I fell behind on rebasing/testing so I need to bring it up to date.
Assuming the arm folks are okay with the approach, we can bring it
in for kernel.org testing once I'm finished.

Thanks,
Laura

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

end of thread, other threads:[~2018-07-18 21:10 UTC | newest]

Thread overview: 76+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-06 14:22 [PATCH v11 0/6] Introduce the STACKLEAK feature and a test for it Alexander Popov
2018-04-06 14:22 ` [PATCH v11 1/6] gcc-plugins: Clean up the cgraph_create_edge* macros Alexander Popov
2018-04-06 14:22 ` [PATCH v11 2/6] x86/entry: Add STACKLEAK erasing the kernel stack at the end of syscalls Alexander Popov
2018-04-16 18:29   ` Kees Cook
2018-04-18 18:33     ` Laura Abbott
2018-04-18 18:50     ` Dave Hansen
2018-04-24  1:03       ` Kees Cook
2018-04-24  4:23   ` Dave Hansen
2018-04-30 23:48     ` Kees Cook
2018-05-02  8:42       ` Thomas Gleixner
2018-05-02 12:38         ` Kees Cook
2018-05-02 12:39           ` Thomas Gleixner
2018-05-02 12:51             ` Kees Cook
2018-05-02 21:02               ` Kees Cook
2018-05-06 10:04                 ` Thomas Gleixner
2018-04-06 14:22 ` [PATCH v11 3/6] gcc-plugins: Add STACKLEAK plugin for tracking the kernel stack Alexander Popov
2018-04-06 14:22 ` [PATCH v11 4/6] lkdtm: Add a test for STACKLEAK Alexander Popov
2018-04-06 14:22 ` [PATCH v11 5/6] fs/proc: Show STACKLEAK metrics in the /proc file system Alexander Popov
2018-04-06 14:22 ` [PATCH v11 6/6] doc: self-protection: Add information about STACKLEAK feature Alexander Popov
2018-05-02 20:33 ` [PATCH 0/2] Stackleak for arm64 Laura Abbott
2018-05-02 20:33   ` Laura Abbott
2018-05-02 20:33   ` [PATCH 1/2] stackleak: Update " Laura Abbott
2018-05-02 20:33     ` Laura Abbott
2018-05-02 20:33   ` [PATCH 2/2] arm64: Clear the stack Laura Abbott
2018-05-02 20:33     ` Laura Abbott
2018-05-02 21:31     ` Kees Cook
2018-05-02 21:31       ` Kees Cook
2018-05-02 23:07       ` Laura Abbott
2018-05-02 23:07         ` Laura Abbott
2018-05-02 23:37         ` Kees Cook
2018-05-02 23:37           ` Kees Cook
2018-05-03 16:05         ` Alexander Popov
2018-05-03 16:05           ` Alexander Popov
2018-05-03 16:45           ` Kees Cook
2018-05-03 16:45             ` Kees Cook
2018-05-03  7:19     ` Mark Rutland
2018-05-03  7:19       ` Mark Rutland
2018-05-03 11:37       ` Ard Biesheuvel
2018-05-03 11:37         ` Ard Biesheuvel
2018-05-03 17:33       ` Alexander Popov
2018-05-03 17:33         ` Alexander Popov
2018-05-03 19:09         ` Laura Abbott
2018-05-03 19:09           ` Laura Abbott
2018-05-04  8:30           ` Alexander Popov
2018-05-04  8:30             ` Alexander Popov
2018-05-04 11:09         ` Mark Rutland
2018-05-04 11:09           ` Mark Rutland
2018-05-06  8:22           ` Alexander Popov
2018-05-06  8:22             ` Alexander Popov
2018-05-11 15:50             ` Alexander Popov
2018-05-11 15:50               ` Alexander Popov
2018-05-11 16:13               ` Mark Rutland
2018-05-11 16:13                 ` Mark Rutland
2018-05-13  8:40                 ` Alexander Popov
2018-05-13  8:40                   ` Alexander Popov
2018-05-14  5:15                   ` Mark Rutland
2018-05-14  5:15                     ` Mark Rutland
2018-05-14  9:35                     ` Alexander Popov
2018-05-14  9:35                       ` Alexander Popov
2018-05-14 10:06                       ` Mark Rutland
2018-05-14 10:06                         ` Mark Rutland
2018-05-14 13:53                         ` Alexander Popov
2018-05-14 13:53                           ` Alexander Popov
2018-05-14 14:07                           ` Mark Rutland
2018-05-14 14:07                             ` Mark Rutland
2018-05-03 19:00       ` Laura Abbott
2018-05-03 19:00         ` Laura Abbott
2018-05-04 11:16         ` Mark Rutland
2018-05-04 11:16           ` Mark Rutland
2018-05-14 18:55 ` [PATCH v11 0/6] Introduce the STACKLEAK feature and a test for it Laura Abbott
  -- strict thread matches above, loose matches on Subject: below --
2018-07-11 20:36 [PATCH v14 " Alexander Popov
2018-07-18 21:10 ` [PATCH 0/2] Stackleak for arm64 Laura Abbott
2018-07-18 21:10   ` Laura Abbott
2018-02-20 23:33 [PATCH RFC v8 0/6] Introduce the STACKLEAK feature and a test for it Laura Abbott
2018-02-21  1:13 ` [PATCH 0/2] Stackleak for arm64 Laura Abbott
2018-02-21  1:13   ` Laura Abbott
2018-02-21 14:48   ` Alexander Popov
2018-02-21 14:48     ` Alexander Popov

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.