From: Will Deacon <will.deacon@arm.com>
To: Kees Cook <keescook@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Jann Horn <jannh@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
Michal Hocko <mhocko@suse.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [RFC PATCH 0/4] Allow tasks to have their user stack pointer sanity checked
Date: Wed, 13 Feb 2019 13:19:16 +0000 [thread overview]
Message-ID: <20190213131915.GC5875@brain-police> (raw)
In-Reply-To: <CAGXu5jJk7zpKzx0DrBRmJvAoPDEMUni5bgE-O1xR8_1-p6HAxQ@mail.gmail.com>
Hi Kees,
On Mon, Feb 11, 2019 at 11:12:19AM -0800, Kees Cook wrote:
> On Mon, Feb 11, 2019 at 9:59 AM Will Deacon <will.deacon@arm.com> wrote:
> > I attended an interesting talk at LCA last month that described some of the
> > security features deployed in OpenBSD [1]. One hardening feature that piqued
> > my interest was, on syscall entry and page faults from userspace, checking
> > that the user stack pointer for a task points at pages that were either
> > allocated by the kernel for the initial process stack of mapped with mmap()
> > using the MAP_STACK flag. This acts as a basic defense against stack
> > pivoting attacks.
>
> I think this is nice to have, yes! Thanks for working on it. It seems
> like this blocks pivots to heap -- relocating to a groomed stack area
> would still be allowed. Regardless, this does narrow the scope of such
> attacks quite nicely.
>
> > The problem with this checking is that it is a retrospective tightening
> > of the ABI, but that hasn't stopped me hacking it together behind a couple
> > of prctl() options.
>
> MAP_STACK has been around for a long time, so I think anything using
> threads via glibc should be "covered". I would assume this would mean
> that glibc could set the prctl() for such users. I suspect there are a
> lot of open-coded threading implementations, though. It'd be
> interesting to see how many need modification.
>
> Given that this is behind a prctl(), it seems the CONFIG isn't needed?
I wanted to keep the CONFIG because we grow task_struct and maybe somebody
cares about that (many of the other fields in there are guarded).
> > Anyway, it was fun to implement so I figured I'd post it as an RFC.
>
> Thanks! I'd love to see an x86 counterpart to the sycall check too.
I'll take a quick look. I think that, like arm64, x86 moved much of their
entry code into C so it might be really straightforward.
> Did you trying bringing up a full userspace and windowing environment
> with this enabled by default (i.e. forcing init to set the prctls)?
> I'd be curious to see how much (if anything) goes boom. :)
So far I haven't found anything other than my targetted testcase which
explodes. However, I would fully expect some JITs to go wrong and probably
also some uses of sigaltstack().
> Reviewed-by: Kees Cook <keescook@chromium.org>
Thanks!
Will
prev parent reply other threads:[~2019-02-13 13:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-11 17:59 Will Deacon
2019-02-11 17:59 ` [RFC PATCH 1/4] mm: Check user stack pointer is mapped with MAP_STACK Will Deacon
2019-02-11 17:59 ` [RFC PATCH 2/4] mm: Expose user stack pointer checking via prctl() Will Deacon
2019-02-11 17:59 ` [RFC PATCH 3/4] mm: Add kconfig entries for user stack pointer checking Will Deacon
2019-02-11 17:59 ` [RFC PATCH 4/4] arm64: Check user stack pointer on syscall entry Will Deacon
2019-02-11 19:12 ` [RFC PATCH 0/4] Allow tasks to have their user stack pointer sanity checked Kees Cook
2019-02-13 13:19 ` Will Deacon [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=20190213131915.GC5875@brain-police \
--to=will.deacon@arm.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=peterz@infradead.org \
--cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®