From nobody Mon Oct 30 17:56:17 2023 X-Original-To: dev-commits-src-main@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 4SK1D152Bfz4yDgp; Mon, 30 Oct 2023 17:56:17 +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 4SK1D14MTgz3Y35; Mon, 30 Oct 2023 17:56:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698688577; 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=Hr3Lv/agYZ834tB/y1jL+Zl9IRqIHAdYE4rlTWWVtnc=; b=rIdRViuYWdA/5fp0f/2DArl0BcuQ5cMYqpCQ+mQRzteolKf3Kcjn/tw5kE2a1Mj9aDQ3Vw 5QAOD9KOPluJ3sbm0y/73sTibK5TfcaLML7b7R5awoLdvh6jRmEC4qFcIcfjcF7be1BVQg 1uH7JWdPk0BdiZBm2tcnBmloTtN46lALNYlWh+kCFiD8cvhzSIh1ycT5bBjfkeu+WASOH+ 6FX9IjT+iNYuv6sM1lAOKrN4ZurJI9yeJvBHf8t8GUjt47iP0+Jn7d6kWWHgMB5Pbiq3D7 r3zqz1JXE1ZahTO8HOhA7WYHu5PL7qlk46FiPEArhjSPagoB+UD7TqSsn8BvxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698688577; 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=Hr3Lv/agYZ834tB/y1jL+Zl9IRqIHAdYE4rlTWWVtnc=; b=f3Pnt1v2U/+1egQG73Rlqxy//2xf4FZJmyTgND6P9SomS42ZZbAl4sWCd6nVIkREgVjO/x nRAQOeAMMmu1EC2OgFhVEov4s2vMvav/1x1ID4A32tOYpOtPEKIYKvadp6+c4uWxLd8uAg Hxymsoa3cwvBEwaUYq9TJle4715U1w/TyFVB+r2Dh26O5PoykjfIickUliE0WYahM0wLgU 7dm01xYspK8Nlx9JzLbF5R4JivPFzROmGN3H2j0wRuzGeeH9Md7jNdM1/2f68FZNFkWdfh 2idHpfr1tSijkY678i+Pk+2sW8JlDyvc/HyRzYvvE12BK7sGXOdwP63WKu32mA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698688577; a=rsa-sha256; cv=none; b=p8wX4PyUoRgR/Z0kN1k0QEt/N7rGV9L64y5zgaoXgpCeHDV75+EWxOt8FgJgHvXYZo7t+2 fPhpdxO11E/yuykqsnUga5Jsg3NqwuEdG1yTeyrbbAewuyl3SdrjCuvnciahnMEctpE2Ch ADQorwrdeKR2X0r+Y54BZ/1xqqTrWhN7nK8ffnxToomuYC8QIDIKw6Jq0iIaxfwHQpahbQ 44M5KLQcQA3b92AVnvszikIQTRHKlxBhaPmVglG4y/xPtsdtiY+t5jcy8u3YkIqpdB8JOd +PSqbqiT25BBy1ku7i/RLRq9lhYxc5LkoQof2FemUzp6mTcF56T1+4c+j7Decw== 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 4SK1D135yWzWkL; Mon, 30 Oct 2023 17:56:17 +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 39UHuH4m028530; Mon, 30 Oct 2023 17:56:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39UHuHcA028527; Mon, 30 Oct 2023 17:56:17 GMT (envelope-from git) Date: Mon, 30 Oct 2023 17:56:17 GMT Message-Id: <202310301756.39UHuHcA028527@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: 522126fea724 - main - csu: Teach csu about PAC and BTI List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 522126fea72419fae344fbcb897b41588909308a Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=522126fea72419fae344fbcb897b41588909308a commit 522126fea72419fae344fbcb897b41588909308a Author: Andrew Turner AuthorDate: 2023-10-12 10:03:37 +0000 Commit: Andrew Turner CommitDate: 2023-10-30 17:55:44 +0000 csu: Teach csu about PAC and BTI Add the Branch Target Identification (BTI) note to libc assembly sources and Pointer Authentication Code (PAC) instructions to _init and _fini. _init and _fini may be called indirectly so need a BTI landing pad. As they are non-leaf functions use the appropriate PAC instruction that also guards against changing the link register. As all object files need the note for any binary using these object files we need to insert it in all asm files. Reviewed by: markj Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D42227 --- lib/csu/aarch64/crt1_s.S | 4 ++++ lib/csu/aarch64/crti.S | 5 +++++ lib/csu/aarch64/crtn.S | 6 ++++++ lib/csu/common/crtbrand.S | 5 +++++ lib/csu/common/feature_note.S | 5 +++++ lib/csu/common/ignore_init_note.S | 5 +++++ 6 files changed, 30 insertions(+) diff --git a/lib/csu/aarch64/crt1_s.S b/lib/csu/aarch64/crt1_s.S index 97b4bff35a0b..981cf4653efd 100644 --- a/lib/csu/aarch64/crt1_s.S +++ b/lib/csu/aarch64/crt1_s.S @@ -30,6 +30,8 @@ */ #include +#include + /* * The program entry point * void _start(char **ap, void (*cleanup)(void)) __dead2 @@ -62,3 +64,5 @@ eprol: END(_start) .section .note.GNU-stack,"",@progbits + +GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) diff --git a/lib/csu/aarch64/crti.S b/lib/csu/aarch64/crti.S index 0a20f4c5e314..8bd2dfac1494 100644 --- a/lib/csu/aarch64/crti.S +++ b/lib/csu/aarch64/crti.S @@ -28,11 +28,14 @@ */ #include +#include + .section .init,"ax",@progbits .align 4 .globl _init .type _init,@function _init: + PAC_LR_SIGN stp x29, x30, [sp, #-16]! mov x29, sp @@ -41,6 +44,8 @@ _init: .globl _fini .type _fini,@function _fini: + PAC_LR_SIGN stp x29, x30, [sp, #-16]! mov x29, sp +GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) diff --git a/lib/csu/aarch64/crtn.S b/lib/csu/aarch64/crtn.S index 924aa36aa045..441411f0ab83 100644 --- a/lib/csu/aarch64/crtn.S +++ b/lib/csu/aarch64/crtn.S @@ -28,13 +28,19 @@ */ #include +#include + .section .init,"ax",@progbits ldp x29, x30, [sp], #16 + PAC_LR_AUTH ret .section .fini,"ax",@progbits ldp x29, x30, [sp], #16 + PAC_LR_AUTH ret .section .note.GNU-stack,"",%progbits + +GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) diff --git a/lib/csu/common/crtbrand.S b/lib/csu/common/crtbrand.S index 0ed86bfba2b2..b59e2fd8056b 100644 --- a/lib/csu/common/crtbrand.S +++ b/lib/csu/common/crtbrand.S @@ -47,3 +47,8 @@ 4: .section .note.GNU-stack,"",%progbits + +#ifdef __aarch64__ +/* This is needed in all objects for BTI to be used in the linked elf file */ +GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) +#endif diff --git a/lib/csu/common/feature_note.S b/lib/csu/common/feature_note.S index 343d2a9262e2..5c1d56d4cde1 100644 --- a/lib/csu/common/feature_note.S +++ b/lib/csu/common/feature_note.S @@ -40,3 +40,8 @@ 4: .section .note.GNU-stack,"",%progbits + +#ifdef __aarch64__ +/* This is needed in all objects for BTI to be used in the linked elf file */ +GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) +#endif diff --git a/lib/csu/common/ignore_init_note.S b/lib/csu/common/ignore_init_note.S index fa37a8990538..57fb4e8f4d51 100644 --- a/lib/csu/common/ignore_init_note.S +++ b/lib/csu/common/ignore_init_note.S @@ -41,3 +41,8 @@ 4: .section .note.GNU-stack,"",%progbits + +#ifdef __aarch64__ +/* This is needed in all objects for BTI to be used in the linked elf file */ +GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) +#endif