From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ucuOAsY9BGk2yRMAWB0awg (envelope-from ) for ; Fri, 31 Oct 2025 00:40:38 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=SXvlt8HU; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F07301E057; Fri, 31 Oct 2025 00:40:37 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 37D6A1E057 for ; Fri, 31 Oct 2025 00:40:37 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A51B3385841B for ; Fri, 31 Oct 2025 04:40:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A51B3385841B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=SXvlt8HU Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id 8208D3858D39 for ; Fri, 31 Oct 2025 04:39:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8208D3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8208D3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::530 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761885594; cv=none; b=AgxR5RTf+jBDi2n0LL4najw+4c/gpMDghavq1GvZhBVVGZRlpHewIe5Zi2OGkhXCnFtDIrta7mHpngafb7NFn6F6WlwlCMIJUlh4jMoA8eJE3S73Q/U40WfbmQryeMaq9EptCWfANTUQT0Qv1+YcUG2d9j0/UWSBN3O0Lzt8EcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761885594; c=relaxed/simple; bh=frS0ppsn+HAeXtGA90dBQGBOuUf8vRqOLRPUpehqrhc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=L3WTQoB1PSZOKPxH6kVZhSCnOseILiw74JfRwRtHPsCB/IQV7NFdrTsQ6NV49CT8GQdDOQ2wCUUsF5GZMBwTpiPo5F93DMfh9mX/YfloBN5KiuWnim5i0t8gJpjExEMsOYKACZqvkNhpN2nyqRA/k22cymeX+Uow8BlWjWx6V6E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8208D3858D39 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-b6cea7c527bso1434248a12.3 for ; Thu, 30 Oct 2025 21:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761885593; x=1762490393; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/EpTLsPqs8+vAoXbJvHQTbftQFnZvDpG2qRQ6RMrmr4=; b=SXvlt8HUwB3ZpKyJGFh7j7oM5SiFf0h9QlV63nfG4GiVI2pmYArmjk2cV9EiEWFSUc fk+sYZEKtmWAUrxiE/A1hEkxl8OV/dC1Gauz838MkKOJNe+4W41kjGTDb6Gq16tO5W+r 09WcH4lWPA3Pc9UEo5+DsUtN2k07I/pzB5g7FKkRqdP5XfZVwNy3iQI1BWr9M2NSMxTX Rcy2uXUqfRMGuWkX1gkj+7jDlQE42ZIX4q1MN4XYIQj5MRHBoC+k5TWtrwyl5XCHSz9b 9XR0q7X9DUEWvymaB4Ucmth0KMwaFJ1f7YXFLSoVjq2vsHjGTzPU8z8Ndip52kAMW6/Y HO6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761885593; x=1762490393; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=/EpTLsPqs8+vAoXbJvHQTbftQFnZvDpG2qRQ6RMrmr4=; b=Bis/ijDH0qSpSKSQxz1zJT46WdjvaUjYUBOeQDujlZQAJ6BoOwFiXkzqA/BiEVZ3+f FWTddXWYz9Vu66yr9B6F1D0Dh+Zp2Lxk+i9X/7PowDTM6/wdzD4+uFHTanLdZcPlb7bf /i11UwJ6+IDSi6cwyLeeYYIp7XQ50l+KxIQVNWvZg8hHaUBZgvqxK84vvQa0/MzK/e6i 5fLeOe8LXbjnbvcleDJAYMCcUnIr2zFHQ8yXX1SAAK+ZKwTXQevSKH+T5LpIrL88FY1s N73bWJM//eC0AmHjNcvwue1siEF6Ton3wDUWrvz7d+LVaKk1OYIDsDSOJDYIsYWZO07d /sZQ== X-Forwarded-Encrypted: i=1; AJvYcCWC54eyv8E3/KIUln6TN9LK4zTX66wlWv511mWpw7wgCIMYoby0VJev+kGO+AZ3vmLEmVdnDf50o/B+sg==@sourceware.org X-Gm-Message-State: AOJu0Yzh1KB86FLH2JthnTy9JDjP0rHbx7N8xFO3eu4kW0b4KHiew68H H7cEpjJ3sGk34SI0cFFLIf/7QQzEnMi4I1g58DGCFzyoD3PEskADr2vC1uDb6WdHW8o= X-Gm-Gg: ASbGncusEPhQS0bIn48EKJ3yiNnZkc5fwreJ3EjyLYLuvnk5FDtBlMxz1vDzhSIJlI6 10lkEI1/Dv4Rbw4kk/zqnrETltyAqdItMxHMcv0cRk8OrTYq5o8MkcYUAS9diazn9BVWUwEeqni 8YoA0KkB3Hna6B/XEScD03+9qCFCN7vgAFUld1/FOejmePzUsgZCwIAmOQVhxV1iW2AIYNUpRsM bKw8yXn8kMzXVWaoVEasxXHEN1fkpMd9i3hBcxfB0gDSRg4UW48ZkYQBiZlKRsk3IffIPK8870v RpQn3TZD6/cCIEIPTcFozzwqhNNgUYf86AHVFPfql2FhbDRmLFjoe/npre399Wj48+ecXheJeg+ o1ujeDuQ5/LyuRaY0AfsCUFuydjAVmso1R4xpQyctsJwVfQHUY/4rrcuzPmrX3F1HH/RgBMHLOU 3/OCY1seaNpKg/ox+/EujJ X-Google-Smtp-Source: AGHT+IHhvhH6pi6332N9DNFhWUwjBZU4ParkY9RA5bX338Gd5m2/2kFhki3AsbegtYtwz2RB4vNurw== X-Received: by 2002:a17:902:e890:b0:269:b6c8:4a4b with SMTP id d9443c01a7336-2951a362016mr32003215ad.6.1761885593474; Thu, 30 Oct 2025 21:39:53 -0700 (PDT) Received: from localhost ([2804:14d:7e39:88d6:dd80:7850:7b40:c343]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29526871063sm7284055ad.21.2025.10.30.21.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Oct 2025 21:39:52 -0700 (PDT) From: Thiago Jung Bauermann To: "Schimpe, Christina" Cc: Eli Zaretskii , "gdb-patches@sourceware.org" Subject: Re: [PATCH 6/9] gdb: Implement 'bt shadow' to print the shadow stack backtrace. In-Reply-To: (Christina Schimpe's message of "Mon, 13 Oct 2025 07:19:04 +0000") References: <20250923111842.4091694-1-christina.schimpe@intel.com> <20250923111842.4091694-7-christina.schimpe@intel.com> <86y0q5crwq.fsf@gnu.org> <871pn7pply.fsf@linaro.org> User-Agent: mu4e 1.12.11; emacs 30.2 Date: Fri, 31 Oct 2025 01:39:50 -0300 Message-ID: <87pla3r8fd.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org "Schimpe, Christina" writes: >> -----Original Message----- >> From: Thiago Jung Bauermann >> Sent: Monday, October 13, 2025 3:17 AM >> To: Schimpe, Christina >> Cc: Eli Zaretskii ; gdb-patches@sourceware.org >> Subject: Re: [PATCH 6/9] gdb: Implement 'bt shadow' to print the shadow >> stack backtrace. >>=20 >> Hello, >>=20 >> "Schimpe, Christina" writes: >>=20 >> >> -----Original Message----- >> >> From: Eli Zaretskii >> >> Sent: Tuesday, September 23, 2025 1:47 PM >> >> To: Schimpe, Christina >> >> Cc: gdb-patches@sourceware.org >> >> Subject: Re: [PATCH 6/9] gdb: Implement 'bt shadow' to print the >> >> shadow stack backtrace. >> >> >> >> > From: Christina Schimpe >> >> > Date: Tue, 23 Sep 2025 11:18:39 +0000 >> >> > >> >> > Add a subcommand 'bt shadow' for the ordinary backtrace command >> >> > which prints the shadow stack backtrace. >> >> > Similar to the ordinary backtrace command 'bt shadow' can be >> >> > configured using COUNT and the command line option -frame-info. >> >> > However, we always print the address and the command is not >> >> > affected by the setting "print address" as well as the setting >> >> > "print frame-info >> >> location-and-address". >> >> > Also we do not print the frame arguments. >> >> > >> >> > Usage: backtrace|bt shadow [OPTION]... [COUNT | -COUNT] >> >> > >> >> > Help output: >> >> > ~~ >> >> > (gdb) help bt shadow >> >> > Print backtrace of all shadow stack frames, or innermost COUNT fram= es. >> >> > Usage: backtrace shadow [OPTION]... [COUNT | -COUNT] >> >> >> >> We have just got rid of qualifier arguments like "full" >> >> and "hide". Instead of introducing qualifier arguments anew, why not >> >> go the way of thread-related commands and add a new command >> "shadow", >> >> so the user could say "shadow backtrace" and maybe in the future also >> >> other sub- commands? >> > >> > This has been discussed in a thread years ago: >> > https://sourceware.org/pipermail/gdb/2023-December/051024.html >> > The direction was to make it part of the ordinary bt command. I think Eli has a good point here, about "bt shadow" going in the opposite direction of the tendency in the backtrace command of moving away from subcommands. From its help entry: (gdb) help backtrace =E2=8B=AE For backward compatibility, the following qualifiers are supported: full - same as -full option. no-filters - same as -no-filters option. hide - same as -hide. One way to address that is what Eli suggested, but another is to go with a "-shadow" option. >> > Currently, we don't plan any further commands for the shadow stack. >> > But maybe for ARM's Guarded Control Stack any further options are >> planned? >> > I added Thiago in cc here. Maybe he has some more input. >>=20 >> Yes, I plan to add two commands for AArch64 Guarded Control Stack, as >> mentioned in that thread: >>=20 >> https://inbox.sourceware.org/gdb/87h6kbfazh.fsf@linaro.org/ >>=20 >> In that email, I suggested putting them under "info shadow-stack", but l= ater >> the people in the thread considered that just adding a top-level "shadow- >> stack" command would be better. >>=20 >> I do think that "backtrace -shadow" is a good option, so IMO we could ha= ve >> both it and the "shadow-stack" umbrella command. It could even have >> "shadow-stack backtrace" as an alias to "backtrace -shadow" to improve >> discoverability. > > I have nothing against that I think, are there similar commands in GDB th= at have such an alias feature? There are some tui subcommands that have toplevel aliases, such as "refresh" =E2=86=92 "tui refresh", and "winheight" =E2=86=92 "tui winheight= ". >> You mentioned that x86 doesn't need the "enabled" and "locked" commands >> because for that architecture the user can look in /proc/$PID/status, bu= t with >> those commands I also plan to allow the user to change the enabled and >> locked GCS features. Wouldn't that be useful for x86? > > For x86 the user can configure the shadow stack enabled and locked state = via arch_prctls: > https://docs.kernel.org/next/x86/shstk.html > > Is that possible for GCS, too? > I am not sure if we can easily change it using GDB. We currently only rea= d/write the > shadow stack pointer via ptrace. > > But it is possible to see those states by running "info proc status" in g= db: > [...] > x86_Thread_features: shstk=20 > x86_Thread_features_locked: shstk wrss > > So I'd say we don't really need it, but it might be useful to improve dis= coverability, too. I did a quick experiment making an inferior function call to prctl (75, 0) from GDB but that didn't disable GCS in the inferior. I'll try again tomorrow. But even if it worked, IMO it's a cumbersome way of getting/setting this in= formation. Also, AArch64 doesn't have this information in "info proc status". --=20 Thiago