From: Dave Martin <Dave.Martin@arm.com>
To: Amit Daniel Kachhap <amit.kachhap@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Kees Cook <keescook@chromium.org>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Kristina Martsenko <kristina.martsenko@arm.com>,
Mark Brown <broonie@kernel.org>,
James Morse <james.morse@arm.com>,
Vincenzo Frascino <Vincenzo.Frascino@arm.com>,
Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 2/3] arm64: cpufeature: Modify address authentication cpufeature to exact
Date: Tue, 23 Jun 2020 15:47:49 +0100 [thread overview]
Message-ID: <20200623144749.GZ25945@arm.com> (raw)
In-Reply-To: <d4e29203-7a6b-c6e5-643c-6b0abc670feb@arm.com>
On Tue, Jun 23, 2020 at 06:47:02PM +0530, Amit Daniel Kachhap wrote:
> Hi,
>
> On 6/22/20 8:05 PM, Dave Martin wrote:
> >On Thu, Jun 18, 2020 at 10:40:28AM +0530, Amit Daniel Kachhap wrote:
> >>This patch modifies the address authentication cpufeature type to EXACT
> >>from earlier LOWER_SAFE as the different configurations added for Armv8.6
> >>enhanced PAC have different behaviour and there is no tunable to enable the
> >>lower safe versions.
> >
> >The enancements add no new instructions at EL0, right? And no
> >behavioural change, provided that userspace doesn't care what signing/
> >authentication algorithm is used?
>
> Yes you are correct that no new instructions are added.
>
> >
> >If so then I guess you're correct not to add a new hwcap, but I thought
> >it was worth asking.
> >
> >>non-exact secondary cpus but rather marks them as tainted. This patch fixes
> >>it by replacing the generic match handler with a new handler specific to
> >>ptrauth.
> >>
> >>After this change, if there is any variation in ptrauth configurations in
> >>secondary cpus from boot cpu then those mismatched cpus are parked in an
> >>infinite loop.
> >>
> >>Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
> >>[Suzuki: Introduce new matching function for address authentication]
> >>Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> >
> >Does a corresponding patch need to go to stable? As things stand, I
> >think older kernels that support pointer auth will go wrong on v8.7+
> >hardware that has these features.
> >
> >This patch in its current form may be too heavy for stable, though.
> >
> >See comment below though.
> >
> >>---
> >>Change since v2:
> >> * Added new matching helper function has_address_auth_cpucap as address
> >> authentication cpufeature is now FTR_EXACT. The existing matching function
> >> has_cpuid_feature is specific to LOWER_SAFE.
> >>
> >> arch/arm64/kernel/cpufeature.c | 56 ++++++++++++++++++++++++++++------
> >> 1 file changed, 47 insertions(+), 9 deletions(-)
> >>
> >>diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> >>index 4ae41670c2e6..42670d615555 100644
> >>--- a/arch/arm64/kernel/cpufeature.c
> >>+++ b/arch/arm64/kernel/cpufeature.c
> >>@@ -210,9 +210,9 @@ static const struct arm64_ftr_bits ftr_id_aa64isar1[] = {
> >> ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR1_FCMA_SHIFT, 4, 0),
> >> ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR1_JSCVT_SHIFT, 4, 0),
> >> ARM64_FTR_BITS(FTR_VISIBLE_IF_IS_ENABLED(CONFIG_ARM64_PTR_AUTH),
> >>- FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR1_API_SHIFT, 4, 0),
> >>+ FTR_STRICT, FTR_EXACT, ID_AA64ISAR1_API_SHIFT, 4, 0),
> >> ARM64_FTR_BITS(FTR_VISIBLE_IF_IS_ENABLED(CONFIG_ARM64_PTR_AUTH),
> >>- FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR1_APA_SHIFT, 4, 0),
> >>+ FTR_STRICT, FTR_EXACT, ID_AA64ISAR1_APA_SHIFT, 4, 0),
> >> ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR1_DPB_SHIFT, 4, 0),
> >> ARM64_FTR_END,
> >> };
> >>@@ -1601,11 +1601,49 @@ static void cpu_clear_disr(const struct arm64_cpu_capabilities *__unused)
> >> #endif /* CONFIG_ARM64_RAS_EXTN */
> >> #ifdef CONFIG_ARM64_PTR_AUTH
> >>-static bool has_address_auth(const struct arm64_cpu_capabilities *entry,
> >>- int __unused)
> >>+static bool has_address_auth_cpucap(const struct arm64_cpu_capabilities *entry, int scope)
> >> {
> >>- return __system_matches_cap(ARM64_HAS_ADDRESS_AUTH_ARCH) ||
> >>- __system_matches_cap(ARM64_HAS_ADDRESS_AUTH_IMP_DEF);
> >>+ int local_cpu_auth;
> >>+ static int boot_cpu_auth_arch;
> >>+ static int boot_cpu_auth_imp_def;
> >>+
> >>+ /* We don't expect to be called with SCOPE_SYSTEM */
> >>+ WARN_ON(scope == SCOPE_SYSTEM);
> >>+
> >>+ local_cpu_auth = cpuid_feature_extract_field(__read_sysreg_by_encoding(entry->sys_reg),
> >>+ entry->field_pos, entry->sign);
> >>+ /*
> >>+ * The ptr-auth feature levels are not intercompatible with
> >>+ * lower levels. Hence we must match all the CPUs with that
> >>+ * of the boot CPU. So cache the level of boot CPU and compare
> >>+ * it against the secondary CPUs.
> >>+ */
> >
> >Thinking about this, does it actually matter if different CPUs have
> >different trapping behaviours for ptrauth?
> >
> >If we are guaranteed that the signing algorithm is still compatible
> >across all CPUs, we might get away with it.
>
> You may be right that these protections may not be required practically.
> But the algorithm of each configurations is different so theoretically
> same set of software will produce different behavior on different cpus.
>
> This code initially changed only FTR_EXACT from FTR_LOWE_SAFE. But there
> are many issues identified here [1] in the cpufeature framework so rest
> of the defensive changes added.
>
> [1]: https://www.spinics.net/lists/arm-kernel/msg808238.html
> >
> >Possibly a dumb question -- I haven't checked the specs to find out
> >whether this makes any sense or not.
>
> Your point is valid though.
OK.
Did you see my comment above about patches for stable?
[...]
Cheers
---Dave
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-06-23 14:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-18 5:10 [PATCH v3 0/3] arm64: add Armv8.6 pointer authentication Amit Daniel Kachhap
2020-06-18 5:10 ` [PATCH v3 1/3] arm64: ptrauth: add pointer authentication Armv8.6 enhanced feature Amit Daniel Kachhap
[not found] ` <20200622142255.GS25945@arm.com>
[not found] ` <d1d3b25d-12d8-15d6-086a-d23b36440dd5@arm.com>
2020-06-23 14:45 ` Dave Martin
2020-06-24 7:07 ` Amit Daniel Kachhap
2020-06-18 5:10 ` [PATCH v3 2/3] arm64: cpufeature: Modify address authentication cpufeature to exact Amit Daniel Kachhap
[not found] ` <20200622143503.GT25945@arm.com>
[not found] ` <d4e29203-7a6b-c6e5-643c-6b0abc670feb@arm.com>
2020-06-23 14:47 ` Dave Martin [this message]
2020-06-24 7:13 ` Amit Daniel Kachhap
2020-06-24 7:49 ` Will Deacon
2020-06-24 11:55 ` Amit Daniel Kachhap
2020-06-18 5:10 ` [PATCH v3 3/3] arm64: kprobe: disable probe of fault prone ptrauth instruction Amit Daniel Kachhap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200623144749.GZ25945@arm.com \
--to=dave.martin@arm.com \
--cc=Vincenzo.Frascino@arm.com \
--cc=amit.kachhap@arm.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=keescook@chromium.org \
--cc=kristina.martsenko@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).