From nobody Fri Oct 20 16:04:55 2023 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 4SBqD73Bhbz4xxMC; Fri, 20 Oct 2023 16:04:55 +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 4SBqD72mGZz3Jdn; Fri, 20 Oct 2023 16:04:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697817895; 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=z1fP8TQTR4hy4eKDw2fBlr38jIN+7sy7q8Ryj1g0ZSA=; b=IvZyHmuIMBEGfouO8Zcgr1iPRAFXCmCT1nYGIp08o8S5rxStAzB+dMlWXUhyHzKXjs0XG4 pX4uvv+leQzRB0xJ53aSI1N83hJEZ7iJI1Gf/op3lPwrl4fz/ZEyW96s8HqhdyfenEZ5X0 /K3bbbmo8eNca8gANrOhvboxbaoYo9egWhT7BE4XW/4HfLnzWNB/+Vf0KWYHXrm/AiDby+ mupSv2bzYpX69nDmst4teB7H8aDbqEadpjgzlOyg/LqmDIaTu3uYVrzFiyWcHFc89br741 /wT0n7r5ZLLNnEzj4MX2Ra1xEJk47EHyO+PLjWu0M4NVTJQiNZdqd5QvaYPVJg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697817895; a=rsa-sha256; cv=none; b=PrZgARVLkPdm0E4HigF/5MaHwjoGZwvNes+NDAkDWVOirNKGeCuGoNGRNG2nBun2zv0JTL zkzwomC8uMirig66y14UKO5JA8yraPiMiboL1Kzma/h+GCYwXPeK1kYLQpxrV/Y1fqcbov HVZkflLbPArbbkrVdLmsTc83W8fVODeWVzOs/95E6TClnrgUbJZsx8U64QAaozI4poUSLB Lxi24SXcfR+Zte6RR+DTmTezRrjz50OnJy9wmmtenrC96OuiN/o4KwVPVi+WRR+OnieR0i k+c/zvtsAQ6tz+IN50IKjSj3Fo9AkXFL0fKk25Y89OisR0MwdaP6KFbE/yQDOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697817895; 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=z1fP8TQTR4hy4eKDw2fBlr38jIN+7sy7q8Ryj1g0ZSA=; b=KJOwrrbUquP6dOv54apAF+FgYpYXnGhC9BrFnMX18OnYjletrmvFRUi03P+lk/x+vCLb8V mq4AGWwC5EHd+S7SVQ8y/m1uTfGcggTxeHRnhogZsC7qoULu27G2qKZTAtVK5BF5ykcSUP YR1UTh9c5F0qup4XWNpwrtbOBhBOf3G6gLF75WHMPyoBWWS5g9Mc8meAMVd/pq/OZJwWCH hKlqsFz7SSp1JQ9Cgo9qPi4lp5x1Q66VSrtOhqcdUdPbbJkZYFI52NHJ7tKjO4vMYYMwOt 3wwY/HrX1sZcaumDoXaZ93t6HwNDLN2lojpTe/tFVGQdZeU5j8gWraYlJnl/Zw== 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 4SBqD71q3CzfN2; Fri, 20 Oct 2023 16:04:55 +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 39KG4tbx039411; Fri, 20 Oct 2023 16:04:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39KG4tfJ039408; Fri, 20 Oct 2023 16:04:55 GMT (envelope-from git) Date: Fri, 20 Oct 2023 16:04:55 GMT Message-Id: <202310201604.39KG4tfJ039408@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 2b39a6f68c38 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 2b39a6f68c3839454cd255b91978202cd995182a Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=2b39a6f68c3839454cd255b91978202cd995182a commit 2b39a6f68c3839454cd255b91978202cd995182a Author: Andrew Turner AuthorDate: 2023-10-12 09:48:38 +0000 Commit: Andrew Turner CommitDate: 2023-10-20 16:01:05 +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 --- 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