From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id BtRiCbQmmWojLSMAWB0awg (envelope-from ) for ; Thu, 03 Sep 2026 03:50:12 -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=S3Qek1TI; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 165BD1E09B; Thu, 03 Sep 2026 03:50:12 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.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 autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 1BEBB1E09B for ; Thu, 03 Sep 2026 03:50:11 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1580C4BA903D for ; Thu, 3 Sep 2026 07:50:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1580C4BA903D 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=S3Qek1TI Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by sourceware.org (Postfix) with ESMTPS id 182F04BA2E12 for ; Thu, 3 Sep 2026 07:49:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 182F04BA2E12 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 182F04BA2E12 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788421786; cv=none; b=MZCv9Sz+HfubFOJEOy3e6geWxuwzZZKEth2GA4NBwlWdXHEfwdDINoVvP0sdZ02VGgoqdcVcDnBom8YHc1n+Hec5kM3M/MUilOIvCJMY6iIqvfWhwhpUNDloPZBmzWxtHeGIoeYklfAak87jSxdNivHt4tiI9MfNCVgMWohvjbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788421786; c=relaxed/simple; bh=6caopHrexVCopntDDjnNrmLfeq8njPmf9sx/7kf5uO8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=b4X/aMC5hxiSlQjTx6ryRO9qm21PhLT/Ez+i9QJmXTBUAB+ZSrGjcCevBHrS1F59xLcf/HY9CJvkZirOh7eYQcBlEr/5UyHRqbeSF96jDi6/ykUg96SVBLmx/6Ge/xYycIi28oDvYBPFv9zgX4tgwMEynFTTbgcPhHIm8IkHigc= ARC-Authentication-Results: i=1; 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=S3Qek1TI DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 182F04BA2E12 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-867a943b149so33272667b3.1 for ; Thu, 03 Sep 2026 00:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1788421785; x=1789026585; darn=sourceware.org; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=KFnBvvWNE3aRC1lzrmT8MrezueW/Xic3vHSiHWIfIEA=; b=S3Qek1TI67Yh2PgTUseeuwkhGKoO/Knks2laViWDWpjOoNm9DUnWT0kIUqAju+NSdl NAf1zznqLV8ZKQdHf0jAD6oHNyDzowt+VzgrgVAo3f8PGlX9DA9DdcIekuAhlAOc9hD5 tT7WLmVU9GDENZtfUamsTZWXkHUI8rCHS0BBlRrq+zJN+AVGfLcrMRWpLvfpkMMng3y1 fE4NSakEdbS90KQkLaVaDlngwIZHP+EOrTT9sGYpGdRLLCppcxV+fQvse+bEuO1PuRJX bQgY1ybWp/duDpsSQ3QXCCteoJvHjTKCmtQys+wGqJeF5S/kPBzdOY4vDOuHxKnnlBIG YTVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788421785; x=1789026585; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=KFnBvvWNE3aRC1lzrmT8MrezueW/Xic3vHSiHWIfIEA=; b=G9QJtbeLeSa5BrBqnUw6inrMTMgHu2A7Ob5Bdp22r5Ci0zLIKq83QoSH4cyaPknhUR 68OGHf3HOf4FTql1Ll64igcDVgSLs8q7s0F+xl0uQkZat872elCJgjeUkcOZ+w1APOhX DgB/abCYSFsj+V0coIKUxkwRX/3IhGZvDWAx8UgG/5uIn+Iya3gqw1NAnWp38aM4J4Cs PFH8DSiI/hr5o7amFOx598jUxaqW13uYGuJMxEGUSNbR0BPtvy4uxgsBZ+JM7jSOZn3y oyXIdxNigYUT0kt6lt3hA51OwTyyds83A3UuMQvinLhNtOjeW+o9ADvSzywdVNqDGeMG 91RQ== X-Gm-Message-State: AFuF++m6RLq5BHVE+38kzmw69VI65AsB4DKQf1Og/otY20cNlwVrKml/ c0+M0AI0FlXbm0XK5wsKSYCodV6KQUeRcX909ILIbVv35PYzyTbQ6qiPX6ewM36W/P0= X-Gm-Gg: AYBFou3fCwslaTL9tiXEAa5BQLX4MRCVorue1dvegIgTtrr+kzFlgz4Q9h20JlvILKQ Uur5Ppo28RDCXEc8MmtluCyDXrd/d6oTF94XwpcgxGaikzRsxr/1Ng7EMv9OrX/I9ejuhAwk5yo 4uLzExmj5EG9NbGMIHerNhFm0OKxOoPHoVhLU9ODBWHjF/Vy2eg4fcL6ebBXTt2BPrAzMir4k0q P428O8j3zqx/y36+wK6funNLDoDVw8toEFnxdmhpx4RAGx5S0LKuF0oAU/T2rNbnzA92DaNZ4So rNRQonGdX95h8m1z6xfPzmuOPSZHLWm18GFIVD9MUK6omzc5m+iyrHMoMmiidSK2BlLh+CKWxRV LTMnr/OVz2c6N0ziTpNhaVWRhjo9psRr1dhRrmGxwtemF4OWmMCwVGFan7rqJK7XE4AJHDnorUb 77p80InAdDivUgU6r2XmMTgBxMJupMJBPZiA+OvcewgV5W4TN53N+QlvibyRz26Pp9g0NhNMw= X-Received: by 2002:a05:690c:f03:b0:81e:deab:43af with SMTP id 00721157ae682-86c4e2093ccmr52295367b3.4.1788421780262; Thu, 03 Sep 2026 00:49:40 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id 00721157ae682-86c18ea5fa8sm34544497b3.43.2026.09.03.00.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 00:49:39 -0700 (PDT) From: Thiago Jung Bauermann To: Christina Schimpe Cc: gdb-patches@sourceware.org, tom@tromey.com Subject: Re: [PATCH v4 10/13] gdb: Implement the hook 'is_no_return_shadow_stack_address' for amd64 linux. In-Reply-To: <20260708143639.2214689-11-christina.schimpe@intel.com> (Christina Schimpe's message of "Wed, 8 Jul 2026 14:36:36 +0000") References: <20260708143639.2214689-1-christina.schimpe@intel.com> <20260708143639.2214689-11-christina.schimpe@intel.com> User-Agent: mu4e 1.14.3; emacs 30.2 Date: Thu, 03 Sep 2026 07:49:37 +0000 Message-ID: <87v78mrcz2.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain 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 Christina Schimpe writes: > diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c > index 42a62eaa975..d98415b8989 100644 > --- a/gdb/amd64-linux-tdep.c > +++ b/gdb/amd64-linux-tdep.c > @@ -1960,6 +1960,62 @@ amd64_linux_top_addr_empty_shadow_stack > return addr == range.second; > } > > +/* Return a shadow stack frame info, if the shadow stack pointer SSP > + belongs to a valid shadow stack frame while the element on the shadow > + stack VALUE does not refer to a return address. This can happen, for > + instance, in case of signals. The old shadow stack pointer is pushed > + in a special format with bit 63 set. In case this is true, a valid > + shadow stack frame info is returned with its attributes frame_type and > + non_return_description configured to ssp_frame_type::non_return_frame > + and "", respectively. */ > + > +static std::optional > +amd64_linux_is_no_return_shadow_stack_address > + (gdbarch *gdbarch, const CORE_ADDR ssp, const CORE_ADDR value, > + const unsigned long level) > +{ > + /* SSP must belong to the shadow stack memory range. */ > + std::pair range; > + gdb_assert (gdbarch_address_in_shadow_stack_memory_range (gdbarch, > + ssp, > + &range)); I made this comment at another assert in a previous version of this series, but it's valid here too: Won't this make GDB crash with a misbehaving inferior? It could indeed mean an internal error (GDB somehow got the SSP or range wrong), but it could also be (and probably more likely) an inconsistent state of the inferior. This can happen in a program being debugged so GDB should be able to handle it gracefully, and if possible provide useful information to the user. Maybe turn this into an error ()? > + > + /* In case bit 63 is not configured, the address on the shadow stack > + should be a return address. */ > + constexpr CORE_ADDR mask = (CORE_ADDR) 1 << 63; > + if ((value & mask) == 0) > + return {}; > + > + /* To compare the shadow stack pointer of the previous frame with the > + value of FRAME, we must clear bit 63. */ > + CORE_ADDR shadow_stack_val_cleared = (value & (~mask)); > + > + /* Compute the previous/old SSP. The shadow stack grows downwards. To > + compute the previous shadow stack pointer, we need to increment > + SSP. */ > + CORE_ADDR prev_ssp > + = ssp + gdbarch_shadow_stack_element_size_aligned (gdbarch); > + > + /* We incremented SSP by one element to compute PREV_SSP before. In > + case SSP points to the first element of the shadow stack, PREV_SSP > + must point to the bottom of the shadow stack (RANGE.SECOND), but not > + beyond that address. */ > + gdb_assert (prev_ssp > range.first && prev_ssp <= range.second); > + > + if (shadow_stack_val_cleared == prev_ssp) > + { > + /* Assign the current gdbarch to the new shadow stack frame. Since > + the token is no PC value, do not assign a SAL object. */ > + return std::optional > + ({ssp, value, level, gdbarch, {}, > + ssp_frame_type::non_return_frame, > + {""}, > + ssp_unwind_stop_reason::no_error}); > + } > + > + return {}; > +} > + -- Thiago (he/him)