linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: solar@openwall.com (Solar Designer)
To: linux-arm-kernel@lists.infradead.org
Subject: [kernel-hardening] [PATCH v2 0/5] stackprotector: ascii armor the stack canary
Date: Tue, 19 Sep 2017 19:16:00 +0200	[thread overview]
Message-ID: <20170919171600.GA31441@openwall.com> (raw)
In-Reply-To: <20170524155751.424-1-riel@redhat.com>

On Wed, May 24, 2017 at 11:57:46AM -0400, riel at redhat.com wrote:
> Zero out the first byte of the stack canary value on 64 bit systems,
> in order to mitigate unterminated C string overflows.
> 
> The null byte both prevents C string functions from reading the
> canary, and from writing it if the canary value were guessed or
> obtained through some other means.
>     
> Reducing the entropy by 8 bits is acceptable on 64-bit systems,
> which will still have 56 bits of entropy left, but not on 32
> bit systems, so the "ascii armor" canary is only implemented on
> 64-bit systems.
> 
> Inspired by the "ascii armor" code in execshield and Daniel Micay's
> linux-hardened tree.
> 
> Also see https://github.com/thestinger/linux-hardened/

Brad trolls us all lightly with this trivia question:

https://twitter.com/grsecurity/status/905246423591084033

"For #trivia can you describe one scenario where this change actually
helps exploitation using similar C string funcs?"

I suppose the expected answer is:

The change helps exploitation when the overwriting string ends just
before the canary.  Its NUL overwriting the NUL byte in the canary would
go undetected.  Before this change, there would be a 255/256 chance of
detection.

I hope this was considered.  The change might still be a good tradeoff,
or it might not, depending on which scenarios are more likely (leak of
canary value or the string required in an exploit ending at that exact
byte location), and we probably lack such statistics.

I am not proposing to revert the change.  I had actually contemplated
speaking up when this was discussed, but did not for lack of a better
suggestion.  We could put/require a NUL in the middle of the canary, but
with the full canary being only 64-bit at most that would also make some
attacks easier.

So this is JFYI.  No action needed on it, I think.

Alexander

  parent reply	other threads:[~2017-09-19 17:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24 15:57 [PATCH v2 0/5] stackprotector: ascii armor the stack canary riel at redhat.com
2017-05-24 15:57 ` [PATCH 1/5] random, stackprotect: introduce get_random_canary function riel at redhat.com
2017-05-24 16:15   ` Kees Cook
2017-05-24 15:57 ` [PATCH 2/5] fork, random: use get_random_canary to set tsk->stack_canary riel at redhat.com
2017-05-24 16:16   ` Kees Cook
2017-05-24 15:57 ` [PATCH 3/5] x86: ascii armor the x86_64 boot init stack canary riel at redhat.com
2017-05-24 16:16   ` Kees Cook
2017-05-24 15:57 ` [PATCH 4/5] arm64: ascii armor the arm64 " riel at redhat.com
2017-05-24 16:16   ` Kees Cook
2017-05-24 15:57 ` [PATCH 5/5] sh64: ascii armor the sh64 " riel at redhat.com
2017-05-24 16:34 ` Rik van Riel
2017-05-24 16:35   ` Kees Cook
2017-09-19 17:16 ` Solar Designer [this message]
2017-09-19 20:22   ` [kernel-hardening] [PATCH v2 0/5] stackprotector: ascii armor the " Kees Cook
2017-09-19 21:10   ` Daniel Micay
2017-09-20 11:18   ` Yann Droneaud
2017-09-20 15:03     ` Solar Designer

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=20170919171600.GA31441@openwall.com \
    --to=solar@openwall.com \
    --cc=linux-arm-kernel@lists.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;
as well as URLs for NNTP newsgroup(s).