All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Alexander Popov <alex.popov@linux.com>
Cc: "Kees Cook" <keescook@chromium.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"Kernel Hardening" <kernel-hardening@lists.openwall.com>,
	"Pax Team" <pageexec@freemail.hu>,
	"Brad Spengler" <spender@grsecurity.net>,
	"Andrew Lutomirski" <luto@kernel.org>,
	"Tycho Andersen" <tycho@tycho.ws>,
	"Laura Abbott" <labbott@redhat.com>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Ard Biesheuvel" <ard.biesheuvel@linaro.org>,
	"Borislav Petkov" <bp@alien8.de>,
	"Richard Sandiford" <richard.sandiford@arm.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Peter Anvin" <hpa@zytor.com>,
	"Peter Zijlstra" <a.p.zijlstra@chello.nl>,
	"Dmitry V. Levin" <ldv@altlinux.org>,
	"Emese Revfy" <re.emese@gmail.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Andrey Ryabinin" <aryabinin@virtuozzo.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	"Thomas Garnier" <thgarnie@google.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Josef Bacik" <jbacik@fb.com>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Nick Piggin" <npiggin@gmail.com>,
	"Al Viro" <viro@zeniv.linux.org.uk>,
	"David Miller" <davem@davemloft.net>,
	dingtianhong <dingtianhong@huawei.com>,
	"David Woodhouse" <dwmw@amazon.co.uk>,
	"Josh Poimboeuf" <jpoimboe@redhat.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Dominik Brodowski" <linux@dominikbrodowski.net>,
	"Jürgen Groß" <jgross@suse.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Dan Williams" <dan.j.williams@intel.com>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Mathias Krause" <minipli@googlemail.com>,
	"Vikas Shivappa" <vikas.shivappa@linux.intel.com>,
	"Kyle Huey" <me@kylehuey.com>,
	"Dmitry Safonov" <dsafonov@virtuozzo.com>,
	"Will Deacon" <will.deacon@arm.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Florian Weimer" <fweimer@redhat.com>,
	"Boris Lukashev" <blukashev@sempervictus.com>,
	"Andrey Konovalov" <andreyknvl@google.com>,
	"the arch/x86 maintainers" <x86@kernel.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v14 0/6] Introduce the STACKLEAK feature and a test for it
Date: Mon, 16 Jul 2018 12:13:38 +0200	[thread overview]
Message-ID: <20180716101337.GA30279@gmail.com> (raw)
In-Reply-To: <ae9db092-13fa-101c-1d07-5767631f7611@linux.com>


* Alexander Popov <alex.popov@linux.com> wrote:

> On 16.07.2018 01:44, Ingo Molnar wrote:
> > 
> > * Kees Cook <keescook@chromium.org> wrote:
> > 
> >> On Thu, Jul 12, 2018 at 2:22 PM, Alexander Popov <alex.popov@linux.com> wrote:
> >>> On 12.07.2018 23:50, Ingo Molnar wrote:
> >>>> Let's make sure informed users have an easy runtime way out
> >>>> from the worst of the overhead that doesn't involve "recompile your distro
> >>>> kernel". Also, make it easier to measure and fingerpoint the overhead...
> >>>
> >>> Would you like the following solution?
> >>>
> >>> I'll create the CONFIG_STACKLEAK_RUNTIME_DISABLE config option, which would be
> >>> similar to CONFIG_SECURITY_SELINUX_DISABLE. That option will provide a sysctl
> >>> switch disabling stackleak_erase(), which provides the most of performance penalty.
> >>
> >> I don't think CONFIG/sysctl is the way to go. I'd recommend making it
> >> a boot arg and using a static key, similar to what's happening to
> >> hardened_usercopy:
> > 
> > Why no sysctl? It's a PITA to reboot systems just to turn a stupid knob off.
> > 
> > Also, it's _much_ easier to measure performance impact when there's a sysctl.
> 
> Yes, you are right.
> 
> But I looked carefully and now see the troubles which sysctl would bring us.
> Each 'task_struct' has 'lowest_stack', which must be initialized before enabling
> STACKLEAK. So runtime enabling via sysctl is not plain and may bring race
> conditions.

Firstly, a sysctl could still allow it to be *disabled*, once - which is the most 
important usecase of the sysctl anyway.

Secondly, in the first iteration this could be kept included unconditionally:

	current->lowest_stack = current_top_of_stack() - THREAD_SIZE/64;

... which would keep it initialized and wouldn't be racy, right?

I.e. only the most expensive part of the function, the scanning, would be turned 
off via the sysctl. I submit that this will avoid all measurable aspects of the 1% 
kbuild performance overhead.

A more involved approach can be done in the future if warranted, and the feature 
could be disabled/enabled more thoroughly - but the runtime sysctl would be 
acceptable for me for now, as a first iteration.

> On the other hand, a boot param + static key that can only disable STACKLEAK 
> during __init are much more robust. I'm preparing the patch and performance 
> measurements.

A boot parameter does *not* address the concern I outlined. Why force admins 
reboot a box just to disable something that causes overhead?

Thanks,

	Ingo

  reply	other threads:[~2018-07-16 10:13 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-11 20:36 [PATCH v14 0/6] Introduce the STACKLEAK feature and a test for it Alexander Popov
2018-07-11 20:36 ` [PATCH v14 1/6] gcc-plugins: Clean up the cgraph_create_edge* macros Alexander Popov
2018-07-11 20:36 ` [PATCH v14 2/6] x86/entry: Add STACKLEAK erasing the kernel stack at the end of syscalls Alexander Popov
2018-07-11 20:36 ` [PATCH v14 3/6] gcc-plugins: Add STACKLEAK plugin for tracking the kernel stack Alexander Popov
2018-07-11 20:36 ` [PATCH v14 4/6] lkdtm: Add a test for STACKLEAK Alexander Popov
2018-07-11 20:36 ` [PATCH v14 5/6] fs/proc: Show STACKLEAK metrics in the /proc file system Alexander Popov
2018-07-11 20:36 ` [PATCH v14 6/6] doc: self-protection: Add information about STACKLEAK feature Alexander Popov
2018-07-11 20:53 ` [PATCH v14 0/6] Introduce the STACKLEAK feature and a test for it Linus Torvalds
2018-07-12 13:59   ` Ingo Molnar
2018-07-12 17:45     ` Kees Cook
2018-07-12 20:50       ` Ingo Molnar
2018-07-12 21:22         ` Alexander Popov
2018-07-12 21:32           ` Kees Cook
2018-07-12 21:37             ` Alexander Popov
2018-07-15 22:44             ` Ingo Molnar
2018-07-16  7:24               ` Alexander Popov
2018-07-16 10:13                 ` Ingo Molnar [this message]
2018-07-16 17:48                   ` Alexander Popov
2018-07-17  7:12                     ` Ingo Molnar
2018-07-17 19:58                       ` Kees Cook
2018-07-17 20:45                         ` Ingo Molnar
2018-07-19 11:31                       ` [PATCH v14 7/7] stackleak, sysctl: Allow runtime disabling of kernel stack erasing Alexander Popov
2018-07-24 22:56                         ` Kees Cook
2018-07-24 23:41                           ` Alexander Popov
2018-07-24 23:59                             ` Kees Cook
2018-07-26 10:18                               ` Alexander Popov
2018-07-26 11:11                                 ` [PATCH v14 7/7] stackleak: " Alexander Popov
2018-07-26 16:08                                   ` Kees Cook
2018-07-18 21:10 ` [PATCH 0/2] Stackleak for arm64 Laura Abbott
2018-07-18 21:10   ` Laura Abbott
2018-07-18 21:10   ` [PATCH 1/2] arm64: Introduce current_stack_type Laura Abbott
2018-07-18 21:10     ` Laura Abbott
2018-07-19 11:07     ` Mark Rutland
2018-07-19 11:07       ` Mark Rutland
2018-07-18 21:10   ` [PATCH 2/2] arm64: Clear the stack Laura Abbott
2018-07-18 21:10     ` Laura Abbott
2018-07-19  2:20     ` Kees Cook
2018-07-19  2:20       ` Kees Cook
2018-07-19 10:41     ` Alexander Popov
2018-07-19 10:41       ` Alexander Popov
2018-07-19 11:41     ` Mark Rutland
2018-07-19 11:41       ` Mark Rutland
2018-07-19 23:28 ` [PATCHv2 0/2] Stackleak for arm64 Laura Abbott
2018-07-19 23:28   ` Laura Abbott
2018-07-19 23:28   ` [PATCHv2 1/2] arm64: Add stack information to on_accessible_stack Laura Abbott
2018-07-19 23:28     ` Laura Abbott
2018-07-20  6:38     ` Mark Rutland
2018-07-20  6:38       ` Mark Rutland
2018-07-19 23:28   ` [PATCHv2 2/2] arm64: Clear the stack Laura Abbott
2018-07-19 23:28     ` Laura Abbott
2018-07-20  4:33     ` Kees Cook
2018-07-20  4:33       ` Kees Cook
2018-07-20  6:39     ` Mark Rutland
2018-07-20  6:39       ` Mark Rutland
2018-07-20 21:41 ` [PATCHv3 0/2] Stackleak for arm64 Laura Abbott
2018-07-20 21:41   ` Laura Abbott
2018-07-20 21:41   ` [PATCHv3 1/2] arm64: Add stack information to on_accessible_stack Laura Abbott
2018-07-20 21:41     ` Laura Abbott
2018-07-20 21:41   ` [PATCHv3 2/2] arm64: Add support for STACKLEAK gcc plugin Laura Abbott
2018-07-20 21:41     ` Laura Abbott
2018-07-24 12:44     ` Alexander Popov
2018-07-24 12:44       ` Alexander Popov
2018-07-24 16:35       ` Kees Cook
2018-07-24 16:35         ` Kees Cook
2018-07-24 16:38   ` [PATCHv3 0/2] Stackleak for arm64 Will Deacon
2018-07-24 16:38     ` Will Deacon
2018-07-25 11:49     ` Will Deacon
2018-07-25 11:49       ` Will Deacon
2018-07-25 22:05       ` Laura Abbott
2018-07-25 22:05         ` Laura Abbott
2018-07-26  9:55         ` Will Deacon
2018-07-26  9:55           ` Will Deacon

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=20180716101337.GA30279@gmail.com \
    --to=mingo@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=alex.popov@linux.com \
    --cc=andreyknvl@google.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=arnd@arndb.de \
    --cc=aryabinin@virtuozzo.com \
    --cc=ast@kernel.org \
    --cc=blukashev@sempervictus.com \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=dingtianhong@huawei.com \
    --cc=dsafonov@virtuozzo.com \
    --cc=dwmw@amazon.co.uk \
    --cc=fweimer@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=jbacik@fb.com \
    --cc=jgross@suse.com \
    --cc=jpoimboe@redhat.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=labbott@redhat.com \
    --cc=ldv@altlinux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=luto@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=me@kylehuey.com \
    --cc=mhiramat@kernel.org \
    --cc=minipli@googlemail.com \
    --cc=npiggin@gmail.com \
    --cc=pageexec@freemail.hu \
    --cc=re.emese@gmail.com \
    --cc=richard.sandiford@arm.com \
    --cc=rostedt@goodmis.org \
    --cc=spender@grsecurity.net \
    --cc=tglx@linutronix.de \
    --cc=thgarnie@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=tycho@tycho.ws \
    --cc=vikas.shivappa@linux.intel.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.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.