From nobody Mon Feb 19 16:45:10 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TdpLG5Bn1z5C9QH; Mon, 19 Feb 2024 16:45:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TdpLG2rckz4bcC; Mon, 19 Feb 2024 16:45:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9u9Yz2elmPKHINsdAhN93lEZGkr1s1SORkXI5Ky68c8=; b=N+vG8G0Tr6Mkw9kdiyDpzk9bn3EKIu30RaAXjD+Y6QyU6x4loUHutl98CX+G0q8SCyL+Df ULVd69SPoiyHJuP+BnQ7SaxMOLv/ZcZKKvpsfWlCdXvpJLA3rosgi/w3pQDO5yySeMpQk9 iwXv3yGdD9PiBqJkFvr+mU/2ijWk73m/hjp6izwrumaGFOXSjQWhSR5UtTwIenHctPmNZ0 FQAtSO7nGywVsmXSV9fopwNtq/dKcnUx0oLKZvs5MNguKwiIN1x0NLRXJKCEj764Eoi/lP 8gWXw+Km8KBH2eWfl0jbrcQligEfELJOThQr5ElGFWyWpihMD1b1K5OzZOnlUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9u9Yz2elmPKHINsdAhN93lEZGkr1s1SORkXI5Ky68c8=; b=XkfYOknToah18Wv2+ZOsQAH91oenHBRFuSTOle2EKrTlkNgizSAN+ZZqyD+liUQF1aDjcZ aRhNKqRf0Mt2gvgSJXRvlFJcfu6IgMs9cj7LJ5dY1nA6sADTGNLDPgGpI8hcYw61Usxb/L x9KtuiE+MYBY8w5tel1vw0yAo0W1BvCnRrvSHbWUYGPXXcKA5GFOuu8bg4QfLBjipD90YM LMVYIRUjzrasiXqC81/84SjcU1gWioSY8oM3QG0NoT6aO5PVapmEXWNDpzcm53BRYVHNTs MHKd1gbg39oVDcIi196RyMiQqZEBHXOodxXPuYdCpXq3Ys2k0c+yGSRvAbNjwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708361110; a=rsa-sha256; cv=none; b=qVfIxa2Q6hfRbRopB4FSJyDJ13UON5ZZtMtbCUAsKMM38rqrsOKqrHnVCBQi28lZNLyqt4 9rJS1XQovuhRxrfzFE8plwkb3bA5xvboDz8Laldq73GUD9xDxjKmsqKxm9ZXpISV5iuH7t dx4Idm8L3aVait42vTEk/Q4xXuFKh7feeV90H2evW3R3+V2F9AlZWPz1ClZAAfIFK3A7kV WVsTkFAxk/uIJdw3IY5jiv3wQ0BoV7BSzJ2fA8y7ALltgg5eWrdiiFn2l8ZFC5dOcchVP+ P0fwLl2Tc2OPx0Ji8nEdlv+WkFPTQLKrpzb+6cfMoKboJ7DRYS02BzzgEOUHZw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TdpLG1y5PzjDP; Mon, 19 Feb 2024 16:45:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41JGjAOO095671; Mon, 19 Feb 2024 16:45:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41JGjABd095668; Mon, 19 Feb 2024 16:45:10 GMT (envelope-from git) Date: Mon, 19 Feb 2024 16:45:10 GMT Message-Id: <202402191645.41JGjABd095668@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: 977d1ded2991 - stable/14 - arm64: Add PAC instruction macros List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 977d1ded299177114c46f9f6d9a2001959f20996 Auto-Submitted: auto-generated The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=977d1ded299177114c46f9f6d9a2001959f20996 commit 977d1ded299177114c46f9f6d9a2001959f20996 Author: Andrew Turner AuthorDate: 2023-10-12 09:48:38 +0000 Commit: Andrew Turner CommitDate: 2024-02-19 13:11:21 +0000 arm64: Add PAC instruction macros To support Pointer Authentication (PAC) in assembly files add a pair of macros that sign the link register. When used before storing to the stack it will allow hardware to detect if it has changed before using it in the return instruction. Reviewed by: markj, emaste Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D42226 (cherry picked from commit 2b39a6f68c3839454cd255b91978202cd995182a) --- sys/arm64/include/asm.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sys/arm64/include/asm.h b/sys/arm64/include/asm.h index da3c3df5f647..16be39b3eae4 100644 --- a/sys/arm64/include/asm.h +++ b/sys/arm64/include/asm.h @@ -142,6 +142,28 @@ #define BTI_J #endif +/* + * To help protect against ROP attacks we can use Pointer Authentication + * to sign the return address before pushing it to the stack. + * + * PAC_LR_SIGN can be used at the start of a function to sign the link + * register with the stack pointer as the modifier. As this is in the hint + * space it is safe to use on CPUs that don't implement pointer + * authentication. It can be used in place of the BTI_C instruction above as + * a valid BTI landing pad instruction. + * + * PAC_LR_AUTH is used to authenticate the link register using the stack + * pointer as the modifier. It should be used in any function that uses + * PAC_LR_SIGN. The stack pointer must be identical in each case. + */ +#ifdef __ARM_FEATURE_PAC_DEFAULT +#define PAC_LR_SIGN hint #25 /* paciasp */ +#define PAC_LR_AUTH hint #29 /* autiasp */ +#else +#define PAC_LR_SIGN +#define PAC_LR_AUTH +#endif + /* * GNU_PROPERTY_AARCH64_FEATURE_1_NOTE can be used to insert a note that * the current assembly file is built with Pointer Authentication (PAC) or