public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] x86: Check corrupted return address when unwinding stack
Date: Fri, 30 Sep 2022 13:33:58 -0600	[thread overview]
Message-ID: <e4c42fdf-51e1-876f-945a-f07680896fe7@gmail.com> (raw)
In-Reply-To: <20220921204206.95480-1-hjl.tools@gmail.com>


On 9/21/22 14:42, H.J. Lu via Gcc-patches wrote:
> If shadow stack is enabled, when unwinding stack, we count how many stack
> frames we pop to reach the landing pad and adjust shadow stack by the same
> amount.  When counting the stack frame, we compare the return address on
> normal stack against the return address on shadow stack.  If they don't
> match, return _URC_FATAL_PHASE2_ERROR for the corrupted return address on
> normal stack.  Don't check the return address for
>
> 1. Non-catchable exception where exception_class == 0.  Process will be
> terminated.
> 2. Zero return address which marks the outermost stack frame.
> 3. Signal stack frame since kernel puts a restore token on shadow stack.
>
> 	* unwind-generic.h (_Unwind_Frames_Increment): Add the EXC
> 	argument.
> 	* unwind.inc (_Unwind_RaiseException_Phase2): Pass EXC to
> 	_Unwind_Frames_Increment.
> 	(_Unwind_ForcedUnwind_Phase2): Likewise.
> 	* config/i386/shadow-stack-unwind.h (_Unwind_Frames_Increment):
> 	Take the EXC argument.  Return _URC_FATAL_PHASE2_ERROR if the
> 	return address on normal stack doesn't match the return address
> 	on shadow stack.

The generic bits are fine.  While I'm aware of one other target that 
_might_ need adjustment, it's an out-of-tree target and thus clearly not 
your responsibility.


jeff



  reply	other threads:[~2022-09-30 19:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 20:42 H.J. Lu
2022-09-30 19:33 ` Jeff Law [this message]
2022-10-04 21:32 ` PING^1: " H.J. Lu
2022-10-17  7:24   ` Hongtao Liu

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=e4c42fdf-51e1-876f-945a-f07680896fe7@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).