From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
To: "Schimpe, Christina" <christina.schimpe@intel.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2 0/9] Add new command to print the shadow stack backtrace
Date: Wed, 20 May 2026 23:57:43 -0300 [thread overview]
Message-ID: <87y0hdzcyg.fsf@linaro.org> (raw)
In-Reply-To: <PH0PR11MB7636E1EAD0E9CF524067470BF9032@PH0PR11MB7636.namprd11.prod.outlook.com> (Christina Schimpe's message of "Mon, 18 May 2026 10:10:32 +0000")
Hello Christina,
"Schimpe, Christina" <christina.schimpe@intel.com> writes:
>> -----Original Message-----
>> From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
>> Sent: Donnerstag, 7. Mai 2026 06:14
>> To: Schimpe, Christina <christina.schimpe@intel.com>
>> Cc: gdb-patches@sourceware.org
>> Subject: Re: [PATCH v2 0/9] Add new command to print the shadow stack
>> backtrace
>>
>> > 3) For non-return addresses on the shadow stack, we want to display a
>> > string, as already implemented for signals. For inferior calls, we
>> > also want to display <function called by GDB>. The return address for
>> > inferior calls is pushed onto the shadow stack by GDB, but we
>> > currently don’t have a way to distinguish this address from normal
>> > return addresses. Thiago suggested pushing the return address
>> > together with a marker, but it’s still unclear how this marker should look
>> like.
>>
>> In AArch64 GCS, we can have "cap" entries which are markers in the stack.
>> Bits 63-12 of the entry have to be the address of the cap entry itself, but bits
>> 11-0 can be arbitrary values. I think the equivalent in
>> x86 shadow stacks would be an entry with the 63 bit set. Can the other bits
>> have an arbitrary value?
>>
>> If so, before we push the return address for the inferior call, we could push a
>> cap entry / data entry with a magic value reserved for GDB to mark dummy
>> shadow stack frames. Then GDB would know that the next entry after it
>> would be the return address for the inferior call.
>>
>> Then when printing a shadow stack frame, we can check whether the entry
>> immediately preceding it has the magic value and print "<function called b
>> GDB>".
>
> In a different email I gave an update about this:
> https://sourceware.org/pipermail/gdb-patches/2026-March/225486.html
> This works without pushing anything on the shadow stack, so I'd prefer that solution.
> Would you be ok with that?
Yes, I agree it's a better solution. Glad you found it.
>> The parts from your latest reply:
>>
>> ----
>> >> 3. We can change GDB to also put a marker in the shadow stack when it
>> >> does an inferior function call, and look for it in the shadow stack.
>> >
>> > We call shadow_stack_push in generic GDB code. Do you think we could
>> > find an architecture independent marker ?
>> > Then we can also return true with the gdbarch hook
>> > is_no_return_address and set the string to <function called from gdb>.
>>
>> I don't think we can find an arch independent marker. In x86, I believe the
>> marker would have to have bit 63 set. While in AArch64 bits 63-12 of the
>> entry need to have the same value as the address of the entry itself. Only bits
>> 11-0 of the entry are free to have an arbitrary token value.
>>
>> > I am just not sure if the linux kernel ever decides to extend its
>> > functionality for CET shadow stack and uses the bits that we use for our
>> marker.
>> > In theory the linux kernel could decide to support 32bit shadow stack
>> > for x86 one day, or supervisor shadow stacks – and I am not sure what
>> > bits the kernel might set in the shadow stack elements to support this.
>> > I wonder if we should discuss this in the linux kernel mailing lists.
>>
>> Good idea, it makes sense to coordinate with the kernel people to see if we
>> can/should reserve a magic token/data value to use in GDB for dummy
>> shadow stack frames. I'll ask the arm64 kernel people to see if they have an
>> opinion on the topic.
>
> With my proposed solution this is no longer necessary.
Nice!
>> > 4) For signals, we also want to print <signal handler called>, as in
>> > the normal backtrace. Since in this case we have a normal return
>> > address on the shadow stack, it’s not yet clear to me how to implement
>> this.
>>
>> On AArch64, when calling a signal handler the kernel pushes a signal cap
>> entry where bits 11-0 have the value 0. So to recognize the shadow stack
>> entry which should be labelled "<signal handler called>", we just need to look
>> at the older entry and see if it's the signal cap entry.
>
> That one I solved now differently, too.
> With a bit refactoring I can reuse the "amd64_linux_sigtramp_p" function.
> Do you have sth. similar for ARM?
No but an AArch64 version can be created that would look for the signal
cap that I mentioned, or alternatively (if I'm not mistaken) read the
actual trampoline instructions in the inferior to recognize it.
--
Thiago
(he/him)
next prev parent reply other threads:[~2026-05-21 2:58 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 8:05 Christina Schimpe
2026-01-23 8:05 ` [PATCH v2 1/9] gdb: Generalize handling of the shadow stack pointer Christina Schimpe
2026-02-19 17:55 ` Tom Tromey
2026-02-27 18:09 ` Schimpe, Christina
2026-02-27 18:26 ` Tom Tromey
2026-03-02 11:53 ` Schimpe, Christina
2026-04-09 9:49 ` Schimpe, Christina
2026-04-14 17:34 ` Tom Tromey
2026-04-15 7:35 ` Schimpe, Christina
2026-04-15 15:54 ` Tom Tromey
2026-02-27 22:54 ` Thiago Jung Bauermann
2026-03-06 3:15 ` Thiago Jung Bauermann
2026-03-06 3:57 ` Thiago Jung Bauermann
2026-04-09 11:57 ` Schimpe, Christina
2026-04-10 5:03 ` Thiago Jung Bauermann
2026-04-10 7:53 ` Schimpe, Christina
2026-04-09 12:06 ` Schimpe, Christina
2026-04-10 5:05 ` Thiago Jung Bauermann
2026-01-23 8:05 ` [PATCH v2 2/9] gdb: Refactor 'stack.c:print_frame' Christina Schimpe
2026-01-23 8:05 ` [PATCH v2 3/9] gdb: Introduce 'stack.c:print_pc' function without frame argument Christina Schimpe
2026-01-23 8:05 ` [PATCH v2 4/9] gdb: Refactor 'find_symbol_funname' and 'info_frame_command_core' in stack.c Christina Schimpe
2026-02-19 17:32 ` Tom Tromey
2026-04-09 12:40 ` Schimpe, Christina
2026-01-23 8:05 ` [PATCH v2 5/9] gdb: Refactor 'stack.c:print_frame_info' Christina Schimpe
2026-01-23 8:05 ` [PATCH v2 6/9] gdb: Add command option 'bt -shadow' to print the shadow stack backtrace Christina Schimpe
2026-01-23 8:52 ` Eli Zaretskii
2026-02-13 16:42 ` Schimpe, Christina
2026-04-14 8:43 ` Schimpe, Christina
2026-04-14 11:53 ` Eli Zaretskii
2026-04-14 13:28 ` Schimpe, Christina
2026-04-14 14:12 ` Eli Zaretskii
2026-04-14 15:05 ` Schimpe, Christina
2026-02-19 18:19 ` Tom Tromey
2026-04-09 16:48 ` Schimpe, Christina
2026-03-06 4:31 ` Thiago Jung Bauermann
2026-03-06 9:39 ` Schimpe, Christina
2026-04-09 15:12 ` Schimpe, Christina
2026-04-10 6:21 ` Thiago Jung Bauermann
2026-04-10 12:12 ` Schimpe, Christina
2026-05-12 3:32 ` Thiago Jung Bauermann
2026-05-18 10:06 ` Schimpe, Christina
2026-01-23 8:05 ` [PATCH v2 7/9] gdb: Provide gdbarch hook to distinguish shadow stack backtrace elements Christina Schimpe
2026-01-23 8:47 ` Eli Zaretskii
2026-02-19 17:41 ` Tom Tromey
2026-05-12 3:49 ` Thiago Jung Bauermann
2026-05-18 10:11 ` Schimpe, Christina
2026-01-23 8:05 ` [PATCH v2 8/9] gdb: Implement the hook 'is_no_return_shadow_stack_address' for amd64 linux Christina Schimpe
2026-02-19 17:43 ` Tom Tromey
2026-05-12 3:58 ` Thiago Jung Bauermann
2026-05-18 10:13 ` Schimpe, Christina
2026-01-23 8:05 ` [PATCH v2 9/9] gdb, mi: Add -shadow-stack-list-frames command Christina Schimpe
2026-01-23 8:46 ` Eli Zaretskii
2026-02-13 19:17 ` Schimpe, Christina
2026-02-19 18:26 ` Tom Tromey
2026-04-22 19:25 ` Schimpe, Christina
2026-03-02 12:39 ` [PATCH v2 0/9] Add new command to print the shadow stack backtrace Schimpe, Christina
2026-05-07 4:14 ` Thiago Jung Bauermann
2026-05-07 5:09 ` Thiago Jung Bauermann
2026-05-18 10:08 ` Schimpe, Christina
2026-05-18 10:10 ` Schimpe, Christina
2026-05-21 2:57 ` Thiago Jung Bauermann [this message]
2026-05-18 8:39 ` Schimpe, Christina
2026-05-21 2:23 ` Thiago Jung Bauermann
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=87y0hdzcyg.fsf@linaro.org \
--to=thiago.bauermann@linaro.org \
--cc=christina.schimpe@intel.com \
--cc=gdb-patches@sourceware.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