From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QcbvJCReUWjY9BEAWB0awg (envelope-from ) for ; Tue, 17 Jun 2025 08:23:00 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=SESM2QHz; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 897411E11C; Tue, 17 Jun 2025 08:23:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-10.1 required=5.0 tests=ARC_SIGNED,ARC_VALID, BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE 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 2B9811E089 for ; Tue, 17 Jun 2025 08:22:59 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C96F93A5AF5C for ; Tue, 17 Jun 2025 12:22:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C96F93A5AF5C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=SESM2QHz Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 1734038C458E for ; Tue, 17 Jun 2025 12:20:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1734038C458E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1734038C458E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750162817; cv=none; b=AZuOCklXOAxNmekF1NkY8W47j6ELFXvvjC2K6KDpWK1WA6rymKxOzu0XvZ5KdPtcwGfi52qqkpoPtM8M0RY0r96LXc6mIR6eL0HolcZlytPP6o1R1kUp6IHtXCh/Ipl661f14YU+ngMiSA27wQ8J/NVLz0TJQ/xp8XkV4rRlgSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750162817; c=relaxed/simple; bh=9NAlL5J0LyPwz0KHieEObqrtSVFcH801/xlxFdo4aXU=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=dVcrprtYG82es35Ft7WScFRnHYQUxFZVyy7RO2g+lf2w7niWl3EjY51SiR1WL6RWFLls906eNzXtwITobjITr+k6aocc9/IZhZJZdUoFYIwJaQmk97ycFOSR1aQdkqr6+by5TcdsjYUGzlo/U9VKLfitvAoknipSBmGaabnZ/1A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1734038C458E Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uRVIR-0000xm-Uu; Tue, 17 Jun 2025 08:20:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=iw79sJrprdJG5be+eJEAZy2j2lJeitpIsKm3Zj8yFSs=; b=SESM2QHzozoW JC2Iliz16pypGcxYocF4jKcLOZxwwcOZrU880X1BDzsGUWomRbFD1xpgpOdjmrOX1Uy78OY0dKAoP Sir+UyCjYQG16YCV0pTZzm52q96amQtD6169gBr7mgE5fMEZzR8+BE9As+nj7qTYt8pcD12JIPEh+ 7e3sxxWh7aXiLFDZ6UeFWRU0/mG+KnE63InYLYAPYPV/m49ntKGd/1gYzgnYUT4RVQ1rXMhjjk9GS egPBDYUrWl1UO7mqQf4CYTx/T+VEvAbXMhQ69F7tTu1i/HRZfIBcjTKLtYHZTNr3GnWc5WNk8ZbH5 X6hhHHwdCsjNqVY+T9DZ6g==; Date: Tue, 17 Jun 2025 15:20:07 +0300 Message-Id: <864iweo8zs.fsf@gnu.org> From: Eli Zaretskii To: Christina Schimpe Cc: gdb-patches@sourceware.org, thiago.bauermann@linaro.org In-Reply-To: <20250617121147.1956686-6-christina.schimpe@intel.com> (message from Christina Schimpe on Tue, 17 Jun 2025 12:11:41 +0000) Subject: Re: [PATCH v4 05/11] gdb, gdbserver: Add support of Intel shadow stack pointer register. References: <20250617121147.1956686-1-christina.schimpe@intel.com> <20250617121147.1956686-6-christina.schimpe@intel.com> 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 > From: Christina Schimpe > Cc: thiago.bauermann@linaro.org, > eliz@gnu.org > Date: Tue, 17 Jun 2025 12:11:41 +0000 > > This patch adds the user mode register PL3_SSP which is part of the > Intel(R) Control-Flow Enforcement Technology (CET) feature for support > of shadow stack. > For now, only native and remote debugging support for shadow stack > userspace on amd64 linux are covered by this patch including 64 bit and > x32 support. 32 bit support is not covered due to missing Linux kernel > support. > > This patch requires fixing the test gdb.base/inline-frame-cycle-unwind > which is failing in case the shadow stack pointer is unavailable. > Such a state is possible if shadow stack is disabled for the current thread > but supported by HW. > > This test uses the Python unwinder inline-frame-cycle-unwind.py which fakes > the cyclic stack cycle by reading the pending frame's registers and adding > them to the unwinder: > > ~~~ > for reg in pending_frame.architecture().registers("general"): > val = pending_frame.read_register(reg) > unwinder.add_saved_register(reg, val) > return unwinder > ~~~ > > However, in case the python unwinder is used we add a register (pl3_ssp) that is > unavailable. This leads to a NOT_AVAILABLE_ERROR caught in > gdb/frame-unwind.c:frame_unwind_try_unwinder and it is continued with standard > unwinders. This destroys the faked cyclic behavior and the stack is > further unwinded after frame 5. > > In the working scenario an error should be triggered: > ~~~ > bt > 0 inline_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:49^M > 1 normal_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:32^M > 2 0x000055555555516e in inline_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:45^M > 3 normal_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:32^M > 4 0x000055555555516e in inline_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:45^M > 5 normal_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:32^M > Backtrace stopped: previous frame identical to this frame (corrupt stack?) > (gdb) PASS: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 5: backtrace when the unwind is broken at frame 5 > ~~~ > > To fix the Python unwinder, we simply skip the unavailable registers. > > Reviewed-by: Thiago Jung Bauermann > Reviewed-By: Eli Zaretskii > --- > gdb/NEWS | 3 + > gdb/amd64-linux-nat.c | 17 +++++ > gdb/amd64-linux-tdep.c | 1 + > gdb/amd64-tdep.c | 6 +- > gdb/amd64-tdep.h | 1 + > gdb/arch/amd64.c | 10 +++ > gdb/arch/i386.c | 4 ++ > gdb/arch/x86-linux-tdesc-features.c | 1 + > gdb/doc/gdb.texinfo | 4 ++ > gdb/features/Makefile | 2 + > gdb/features/i386/32bit-ssp.c | 14 ++++ > gdb/features/i386/32bit-ssp.xml | 11 +++ > gdb/features/i386/64bit-ssp.c | 14 ++++ > gdb/features/i386/64bit-ssp.xml | 11 +++ > gdb/i386-tdep.c | 22 +++++- > gdb/i386-tdep.h | 4 ++ > gdb/nat/x86-linux-tdesc.c | 2 + > gdb/nat/x86-linux.c | 55 +++++++++++++++ > gdb/nat/x86-linux.h | 4 ++ > gdb/testsuite/gdb.arch/amd64-shadow-stack.c | 22 ++++++ > gdb/testsuite/gdb.arch/amd64-ssp.exp | 50 +++++++++++++ > .../gdb.base/inline-frame-cycle-unwind.py | 4 ++ > gdb/testsuite/lib/gdb.exp | 70 +++++++++++++++++++ > gdb/x86-linux-nat.c | 50 +++++++++++-- > gdb/x86-linux-nat.h | 11 +++ > gdb/x86-tdep.c | 21 ++++++ > gdb/x86-tdep.h | 9 +++ > gdbserver/linux-x86-low.cc | 28 +++++++- > gdbsupport/x86-xstate.h | 5 +- > 29 files changed, 446 insertions(+), 10 deletions(-) > create mode 100644 gdb/features/i386/32bit-ssp.c > create mode 100644 gdb/features/i386/32bit-ssp.xml > create mode 100644 gdb/features/i386/64bit-ssp.c > create mode 100644 gdb/features/i386/64bit-ssp.xml > create mode 100644 gdb/testsuite/gdb.arch/amd64-shadow-stack.c > create mode 100644 gdb/testsuite/gdb.arch/amd64-ssp.exp The NEWS part is okay, thanks. Reviewed-By: Eli Zaretskii