From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
To: "Aktemur, Baris" <TankutBaris.Aktemur@amd.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
Luis <luis.machado.foss@gmail.com>
Subject: Re: [PATCH] GDB: aarch64: Fix inferior function call if GCS is present but disabled
Date: Wed, 08 Jul 2026 19:43:14 +0000 [thread overview]
Message-ID: <87y0fl5ktp.fsf@linaro.org> (raw)
In-Reply-To: <DM4PR12MB64707671E641F1755CFB13F2F8FF2@DM4PR12MB6470.namprd12.prod.outlook.com> (Baris Aktemur's message of "Wed, 8 Jul 2026 07:50:08 +0000")
Hello Baris,
Thank you for your review!
"Aktemur, Baris" <TankutBaris.Aktemur@amd.com> writes:
>> On AArch64, even if the Guarded Control Stack feature is present on the
>> system the inferior may not have enabled it.
>>
>> There's a bug in GDB's GCS support in that if the system supports GCS,
>> GDB will always push a GCS entry when doing an inferior function call
>> even if the inferior doesn't have it enabled. This causes inferior
>> function calls to fail. E.g.:
>>
>> (gdb) p foo ()
>> Can't write to Guarded Control Stack.
>>
>> The error message is because the GCSPR doesn't point to a valid memory
>> address.
>>
>> Fix by checking whether GCS is enabled in the inferior before trying to
>> push a GCS entry.
>>
>> Regression tested on an aarch64-linux-gnu QEMU VM with GCS present.
>> ---
>>
>> GCS support first appeared in GDB 17, so if this patch is approved for
>> trunk is it ok to also commit it to the branch?
>>
>> gdb/aarch64-tdep.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
>> index 886e7ce1e7b6..b4437dcccc8a 100644
>> --- a/gdb/aarch64-tdep.c
>> +++ b/gdb/aarch64-tdep.c
>> @@ -1934,7 +1934,11 @@ static void
>> aarch64_shadow_stack_push (gdbarch *gdbarch, CORE_ADDR new_addr,
>> regcache *regcache)
>> {
>> - aarch64_push_gcs_entry (regcache, new_addr);
>> + bool gcs_is_enabled;
>> +
>> + gdbarch_get_shadow_stack_pointer (gdbarch, regcache, gcs_is_enabled);
>
> Some analyzer tools may flag this because the return value is not being used.
> Maybe put a `(void)` in front to indicate the return value is being ignored
> deliberately.
Makes sense. I made this change locally:
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index b4437dcccc8a..5b38ff74260c 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -1936,7 +1936,7 @@ aarch64_shadow_stack_push (gdbarch *gdbarch, CORE_ADDR new_addr,
{
bool gcs_is_enabled;
- gdbarch_get_shadow_stack_pointer (gdbarch, regcache, gcs_is_enabled);
+ (void) gdbarch_get_shadow_stack_pointer (gdbarch, regcache, gcs_is_enabled);
if (gcs_is_enabled)
aarch64_push_gcs_entry (regcache, new_addr);
}
--
Thiago
(he/him)
next prev parent reply other threads:[~2026-07-08 19:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 6:03 Thiago Jung Bauermann
2026-07-08 7:50 ` Aktemur, Baris
2026-07-08 19:43 ` Thiago Jung Bauermann [this message]
2026-07-21 16:38 ` Tom Tromey
2026-07-22 20:23 ` Thiago Jung Bauermann
2026-07-22 22:27 ` Tom Tromey
2026-07-19 8:57 ` Luis
2026-07-22 19:59 ` 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=87y0fl5ktp.fsf@linaro.org \
--to=thiago.bauermann@linaro.org \
--cc=TankutBaris.Aktemur@amd.com \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado.foss@gmail.com \
/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