From: Mel Gorman <mgorman@techsingularity.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>,
Kees Cook <keescook@chromium.org>,
Andy Lutomirski <luto@kernel.org>,
Laura Abbott <labbott@redhat.com>,
Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com
Subject: Re: [PATCH v2] fork: Unconditionally clear stack on fork
Date: Thu, 22 Feb 2018 09:53:03 +0000 [thread overview]
Message-ID: <20180222095303.jeepikc5qlbjsal7@techsingularity.net> (raw)
In-Reply-To: <20180221125914.dc95830eada5fb958c13e36b@linux-foundation.org>
On Wed, Feb 21, 2018 at 12:59:14PM -0800, Andrew Morton wrote:
> On Wed, 21 Feb 2018 11:29:33 +0100 Michal Hocko <mhocko@kernel.org> wrote:
>
> > On Tue 20-02-18 18:16:59, Kees Cook wrote:
> > > One of the classes of kernel stack content leaks[1] is exposing the
> > > contents of prior heap or stack contents when a new process stack is
> > > allocated. Normally, those stacks are not zeroed, and the old contents
> > > remain in place. In the face of stack content exposure flaws, those
> > > contents can leak to userspace.
> > >
> > > Fixing this will make the kernel no longer vulnerable to these flaws,
> > > as the stack will be wiped each time a stack is assigned to a new
> > > process. There's not a meaningful change in runtime performance; it
> > > almost looks like it provides a benefit.
> > >
> > > Performing back-to-back kernel builds before:
> > > Run times: 157.86 157.09 158.90 160.94 160.80
> > > Mean: 159.12
> > > Std Dev: 1.54
> > >
> > > and after:
> > > Run times: 159.31 157.34 156.71 158.15 160.81
> > > Mean: 158.46
> > > Std Dev: 1.46
> >
> > /bin/true or similar would be more representative for the worst case
> > but it is good to see that this doesn't have any visible effect on
> > a more real usecase.
>
> Yes, that's a pretty large memset. And while it will populate the CPU
> cache with the stack contents, doing so will evict other things.
>
The lines will also bounce on the child. I expect the zeroing will be a
relatively small percentage of the overall cost. The cost is all elsewhere
such as the the full search that fork does for queueing a task on a CPU
for the first time. Using perf will mask the issue unless the performance
governor is used in this case. Otherwise you hit the weird corner case
whereby perf itself increases CPU utilisation and the cpufreq governor
(even if it's HWP or another hardware-based scheme) will increase the
p-state and it'll appear to run faster.
> So some quite careful quantitative testing is needed here, methinks.
With an emphasis on careful.
--
Mel Gorman
SUSE Labs
prev parent reply other threads:[~2018-02-22 9:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-21 2:16 [PATCH v2] fork: Unconditionally clear stack on fork Kees Cook
2018-02-21 10:29 ` Michal Hocko
2018-02-21 20:59 ` Andrew Morton
2018-02-22 2:15 ` Kees Cook
2018-04-18 16:38 ` Kees Cook
2018-04-18 19:50 ` Andrew Morton
2018-02-22 9:53 ` Mel Gorman [this message]
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=20180222095303.jeepikc5qlbjsal7@techsingularity.net \
--to=mgorman@techsingularity.net \
--cc=akpm@linux-foundation.org \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=labbott@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mhocko@kernel.org \
--cc=rasmus.villemoes@prevas.dk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox