Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp653483pxy; Wed, 5 May 2021 10:24:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywnkpZ74UEuycb7u4S8q9LQNomac1HE0vZAZ8nZOhtDaLiDYBLZg0dWuS/yPq7wsv6qCGR X-Received: by 2002:a05:6a00:7c9:b029:28e:9a2a:8da3 with SMTP id n9-20020a056a0007c9b029028e9a2a8da3mr39296pfu.60.1620235448029; Wed, 05 May 2021 10:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620235448; cv=none; d=google.com; s=arc-20160816; b=tjuHmom+R1xeIABXjEhcY/85k9+GKO8CGZSajt/pjyJyOsCHWyjcZFUTRLFAfdqdp5 aCGeqvET3S2DzoxRRB0TxkS03brMU8A2EXrabI8kmSf2tu7U+iVb+tFkCmWkoGsFxm9k 38IZEfA0Q68QTlTyYqNePg6x0LST7+qeV/msx/fjY2ndqHtavhQS5rf5pwW7RBFcFiDn NMMS3rMCrj6plobE3HzhCzZS7f+HmKqfuCcqY0EmtpmCNjXwbu1E1aWg/UEjtvCTWBHy Nyd83NZYplR5l/XXRSIlfwCuGKCtjA+6HN+VY94njD0yVP0F2n028toCnstQomtdtclp I04w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=+ajaLGN3DWq7vM53h4wEbpFKZs4j98B5ogsm99BGYgc=; b=v+bCj2mXSHPvKwRsKsW9jSHr/WeUCcaXY2/TN23CctDZBfvj/V5l9MWt0MTpQ01rKp L9V/VLCidJluSeRwqQx2btJPeBDwwBw31lCSbgfapgPl5Hta4LZP0F/zjk/0z+YtFQdw mpXuCBXXPkZGlBKZ7H0T23eIuCfeykzvpPYX6xJIsil4oLKWzbF4Ae3Yd1YOXKGXVARf +zNxfxcylzaDuSPtccefthuEUVLbrMAH8Q/69wHHVM2GGQeD0sPahoapBVIi9Xr+UcWB 3NwF2P1FdxQSx8387JURDMyjuuBPXJzv+HDf9vQD6pUAfa0eT2Hetn1wJdH8YT6TVtEa yA+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MbYkLDra; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si5820557pln.260.2021.05.05.10.23.54; Wed, 05 May 2021 10:24:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MbYkLDra; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240619AbhEERV0 (ORCPT + 99 others); Wed, 5 May 2021 13:21:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:35264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238599AbhEERGL (ORCPT ); Wed, 5 May 2021 13:06:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C36EB613F9; Wed, 5 May 2021 16:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620233245; bh=cQH1viTRhYXl+Jt1QORMEhZ6NgeUoG/3eUaMm1SfYc8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MbYkLDraHvZ9Z15LwnUslfVHSDdfqboAaa5IKFnn6G9zp7sn1/r3gMcpBoxkMUS3j jfIF9dGUtff3yDR/xffYdjJN21RFD2UjqEXUYBnVFEm0CLDjPGVbNxfZysA6/nXNTf Shfy//0z2yLErdZqnoEREQp24XMNg/5v9sdO0wZ5HVep7Ze0384kVKada+cAFNUeGK 7E/zM+bS3umqj7k/tSwOrUt7CUJEsBYecVvw57qIA8ra2kwLLemoI4CF0m6+BV58xl rfR9HcoQyemnFn8Ks8VIsUetEivSB6wxW3zeVi8n1YwthuWNWHbPJf9a83fmDuDktE wB6NpT1lFFqqg== Date: Wed, 5 May 2021 17:46:48 +0100 From: Mark Brown To: "Madhavan T. Venkataraman" Cc: jpoimboe@redhat.com, mark.rutland@arm.com, jthierry@redhat.com, catalin.marinas@arm.com, will@kernel.org, jmorris@namei.org, pasha.tatashin@soleen.com, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v3 2/4] arm64: Check the return PC against unreliable code sections Message-ID: <20210505164648.GC4541@sirena.org.uk> References: <65cf4dfbc439b010b50a0c46ec500432acde86d6> <20210503173615.21576-1-madvenka@linux.microsoft.com> <20210503173615.21576-3-madvenka@linux.microsoft.com> <20210504160508.GC7094@sirena.org.uk> <1bd2b177-509a-21d9-e349-9b2388db45eb@linux.microsoft.com> <0f72c4cb-25ef-ee23-49e4-986542be8673@linux.microsoft.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="GPJrCs/72TxItFYR" Content-Disposition: inline In-Reply-To: <0f72c4cb-25ef-ee23-49e4-986542be8673@linux.microsoft.com> X-Cookie: Please ignore previous fortune. User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --GPJrCs/72TxItFYR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 04, 2021 at 02:32:35PM -0500, Madhavan T. Venkataraman wrote: > If you prefer, I could do something like this: >=20 > check_pc: > if (!__kernel_text_address(frame->pc)) > frame->reliable =3D false; >=20 > range =3D lookup_range(frame->pc); >=20 > #ifdef CONFIG_FUNCTION_GRAPH_TRACER > if (tsk->ret_stack && > frame->pc =3D=3D (unsigned long)return_to_handler) { > ... > frame->pc =3D ret_stack->ret; > frame->pc =3D ptrauth_strip_insn_pac(frame->pc); > goto check_pc; > } > #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ > Is that acceptable? I think that works even if it's hard to love the goto, might want some defensiveness to ensure we can't somehow end up in an infinite loop with a sufficiently badly formed stack. --GPJrCs/72TxItFYR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmCSy/cACgkQJNaLcl1U h9ABjAf/fEFuQnVM2PvVSSZ12g8EU3JD2pWnZUmAS5BwePbK0p37pAFxtY+RmvAQ DwaiqGBi0F7QP8FToXUPDsds7X9jQy8+8yHMNbt878ScDIz5SKNuR29m2ADQ/cKr OZD8Jv3poTDRDVUNequtEEqt4T+90tBlCN6ZKBlxH7wV2ArU3cUJ8Oa/vQyouyoc VPzvPAZY1zupyPtDNPzK31AkkyWhhmOZJmckQuJ1p8KC5aKZCRcEvmPA5jX9QYvq oesi89rEjZVhXphISnELRwpfcvJx/O203iRhTbuJ06nU/KxZLBXWAmj/vaXhggog jAkfptyHcleFuFCNNsKFLCY3o/TQ6A== =fJrE -----END PGP SIGNATURE----- --GPJrCs/72TxItFYR--