From: <gregkh@linuxfoundation.org>
To: anshuman.khandual@arm.com,ardb@kernel.org,broonie@kernel.org,catalin.marinas@arm.com,ebiederm@xmission.com,f.fainelli@gmail.com,gregkh@linuxfoundation.org,haibinzhang@tencent.com,hewenliang4@huawei.com,james.morse@arm.com,joey.gouly@arm.com,linux-arm-kernel@lists.infradead.org,mark.rutland@arm.com,peterz@infradead.org,ruanjinjie@huawei.com,sashal@kernel.org,scott@os.amperecomputing.com,stable@kernel.org,will@kernel.org,youngmin.nam@samsung.com,yuzenghui@huawei.com
Cc: <stable-commits@vger.kernel.org>
Subject: Patch "arm64: split EL0/EL1 UNDEF handlers" has been added to the 5.10-stable tree
Date: Mon, 16 Oct 2023 10:02:25 +0200 [thread overview]
Message-ID: <2023101625-qualifier-ahead-11d5@gregkh> (raw)
In-Reply-To: <20231011100545.979577-8-ruanjinjie@huawei.com>
This is a note to let you know that I've just added the patch titled
arm64: split EL0/EL1 UNDEF handlers
to the 5.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
arm64-split-el0-el1-undef-handlers.patch
and it can be found in the queue-5.10 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
From ruanjinjie@huawei.com Wed Oct 11 12:06:35 2023
From: Jinjie Ruan <ruanjinjie@huawei.com>
Date: Wed, 11 Oct 2023 10:05:37 +0000
Subject: arm64: split EL0/EL1 UNDEF handlers
To: <catalin.marinas@arm.com>, <will@kernel.org>, <yuzenghui@huawei.com>, <anshuman.khandual@arm.com>, <gregkh@linuxfoundation.org>, <mark.rutland@arm.com>, <broonie@kernel.org>, <youngmin.nam@samsung.com>, <ardb@kernel.org>, <f.fainelli@gmail.com>, <james.morse@arm.com>, <sashal@kernel.org>, <scott@os.amperecomputing.com>, <ebiederm@xmission.com>, <haibinzhang@tencent.com>, <hewenliang4@huawei.com>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <stable@kernel.org>
Cc: <ruanjinjie@huawei.com>
Message-ID: <20231011100545.979577-8-ruanjinjie@huawei.com>
From: Mark Rutland <mark.rutland@arm.com>
commit 61d64a376ea80f9097e7ea599bcd68671b836dc6 upstream.
In general, exceptions taken from EL1 need to be handled separately from
exceptions taken from EL0, as the logic to handle the two cases can be
significantly divergent, and exceptions taken from EL1 typically have
more stringent requirements on locking and instrumentation.
Subsequent patches will rework the way EL1 UNDEFs are handled in order
to address longstanding soundness issues with instrumentation and RCU.
In preparation for that rework, this patch splits the existing
do_undefinstr() handler into separate do_el0_undef() and do_el1_undef()
handlers.
Prior to this patch, do_undefinstr() was marked with NOKPROBE_SYMBOL(),
preventing instrumentation via kprobes. However, do_undefinstr() invokes
other code which can be instrumented, and:
* For UNDEFINED exceptions taken from EL0, there is no risk of recursion
within kprobes. Therefore it is safe for do_el0_undef to be
instrumented with kprobes, and it does not need to be marked with
NOKPROBE_SYMBOL().
* For UNDEFINED exceptions taken from EL1, either:
(a) The exception is has been taken when manipulating SSBS; these cases
are limited and do not occur within code that can be invoked
recursively via kprobes. Hence, in these cases instrumentation
with kprobes is benign.
(b) The exception has been taken for an unknown reason, as other than
manipulating SSBS we do not expect to take UNDEFINED exceptions
from EL1. Any handling of these exception is best-effort.
... and in either case, marking do_el1_undef() with NOKPROBE_SYMBOL()
isn't sufficient to prevent recursion via kprobes as functions it
calls (including die()) are instrumentable via kprobes.
Hence, it's not worthwhile to mark do_el1_undef() with
NOKPROBE_SYMBOL(). The same applies to do_el1_bti() and do_el1_fpac(),
so their NOKPROBE_SYMBOL() annotations are also removed.
Aside from the new instrumentability, there should be no functional
change as a result of this patch.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20221019144123.612388-3-mark.rutland@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm64/include/asm/exception.h | 3 ++-
arch/arm64/kernel/entry-common.c | 4 ++--
arch/arm64/kernel/traps.c | 22 ++++++++++++----------
3 files changed, 16 insertions(+), 13 deletions(-)
--- a/arch/arm64/include/asm/exception.h
+++ b/arch/arm64/include/asm/exception.h
@@ -33,7 +33,8 @@ asmlinkage void exit_to_user_mode(void);
void arm64_enter_nmi(struct pt_regs *regs);
void arm64_exit_nmi(struct pt_regs *regs);
void do_mem_abort(unsigned long addr, unsigned int esr, struct pt_regs *regs);
-void do_undefinstr(struct pt_regs *regs, unsigned long esr);
+void do_el0_undef(struct pt_regs *regs, unsigned long esr);
+void do_el1_undef(struct pt_regs *regs, unsigned long esr);
void do_el0_bti(struct pt_regs *regs);
void do_el1_bti(struct pt_regs *regs, unsigned long esr);
asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr);
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -136,7 +136,7 @@ static void noinstr el1_undef(struct pt_
{
enter_from_kernel_mode(regs);
local_daif_inherit(regs);
- do_undefinstr(regs, esr);
+ do_el1_undef(regs, esr);
local_daif_mask();
exit_to_kernel_mode(regs);
}
@@ -332,7 +332,7 @@ static void noinstr el0_undef(struct pt_
{
enter_from_user_mode();
local_daif_restore(DAIF_PROCCTX);
- do_undefinstr(regs, esr);
+ do_el0_undef(regs, esr);
}
static void noinstr el0_bti(struct pt_regs *regs)
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -395,7 +395,7 @@ void arm64_notify_segfault(unsigned long
force_signal_inject(SIGSEGV, code, addr, 0);
}
-void do_undefinstr(struct pt_regs *regs, unsigned long esr)
+void do_el0_undef(struct pt_regs *regs, unsigned long esr)
{
/* check for AArch32 breakpoint instructions */
if (!aarch32_break_handler(regs))
@@ -404,12 +404,16 @@ void do_undefinstr(struct pt_regs *regs,
if (call_undef_hook(regs) == 0)
return;
- if (!user_mode(regs))
- die("Oops - Undefined instruction", regs, esr);
-
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
}
-NOKPROBE_SYMBOL(do_undefinstr);
+
+void do_el1_undef(struct pt_regs *regs, unsigned long esr)
+{
+ if (call_undef_hook(regs) == 0)
+ return;
+
+ die("Oops - Undefined instruction", regs, esr);
+}
void do_el0_bti(struct pt_regs *regs)
{
@@ -420,7 +424,6 @@ void do_el1_bti(struct pt_regs *regs, un
{
die("Oops - BTI", regs, esr);
}
-NOKPROBE_SYMBOL(do_el1_bti);
void do_el0_fpac(struct pt_regs *regs, unsigned long esr)
{
@@ -435,7 +438,6 @@ void do_el1_fpac(struct pt_regs *regs, u
*/
die("Oops - FPAC", regs, esr);
}
-NOKPROBE_SYMBOL(do_el1_fpac);
#define __user_cache_maint(insn, address, res) \
if (address >= user_addr_max()) { \
@@ -671,7 +673,7 @@ void do_el0_cp15(unsigned long esr, stru
hook_base = cp15_64_hooks;
break;
default:
- do_undefinstr(regs, esr);
+ do_el0_undef(regs, esr);
return;
}
@@ -686,7 +688,7 @@ void do_el0_cp15(unsigned long esr, stru
* EL0. Fall back to our usual undefined instruction handler
* so that we handle these consistently.
*/
- do_undefinstr(regs, esr);
+ do_el0_undef(regs, esr);
}
#endif
@@ -705,7 +707,7 @@ void do_el0_sys(unsigned long esr, struc
* back to our usual undefined instruction handler so that we handle
* these consistently.
*/
- do_undefinstr(regs, esr);
+ do_el0_undef(regs, esr);
}
static const char *esr_class_str[] = {
Patches currently in stable-queue which might be from ruanjinjie@huawei.com are
queue-5.10/arm64-factor-insn-read-out-of-call_undef_hook.patch
queue-5.10/arm64-rework-el0-mrs-emulation.patch
queue-5.10/arm64-die-pass-err-as-long.patch
queue-5.10/arm64-armv8_deprecated-rework-deprected-instruction-handling.patch
queue-5.10/arm64-armv8_deprecated-fix-unused-function-error.patch
queue-5.10/arm64-armv8_deprecated-move-aarch32-helper-earlier.patch
queue-5.10/arm64-consistently-pass-esr_elx-to-die.patch
queue-5.10/arm64-factor-out-el1-ssbs-emulation-hook.patch
queue-5.10/arm64-report-el1-undefs-better.patch
queue-5.10/arm64-armv8_deprecated-fold-ops-into-insn_emulation.patch
queue-5.10/arm64-rework-bti-exception-handling.patch
queue-5.10/arm64-rework-fpac-exception-handling.patch
queue-5.10/arm64-split-el0-el1-undef-handlers.patch
queue-5.10/arm64-allow-kprobes-on-el0-handlers.patch
queue-5.10/arm64-armv8_deprecated-move-emulation-functions.patch
_______________________________________________
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:[~2023-10-16 8:04 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-11 10:05 [PATCH v5.10 RESEND 00/15] arm64: Fix a concurrency issue in emulation_proc_handler() Jinjie Ruan
2023-10-11 10:05 ` [PATCH v5.10 RESEND 01/15] arm64: report EL1 UNDEFs better Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: report EL1 UNDEFs better" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 02/15] arm64: die(): pass 'err' as long Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: die(): pass 'err' as long" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 03/15] arm64: consistently pass ESR_ELx to die() Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: consistently pass ESR_ELx to die()" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 04/15] arm64: rework FPAC exception handling Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: rework FPAC exception handling" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 05/15] arm64: rework BTI exception handling Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: rework BTI exception handling" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 06/15] arm64: allow kprobes on EL0 handlers Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: allow kprobes on EL0 handlers" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 07/15] arm64: split EL0/EL1 UNDEF handlers Jinjie Ruan
2023-10-16 8:02 ` gregkh [this message]
2023-10-11 10:05 ` [PATCH v5.10 RESEND 08/15] arm64: factor out EL1 SSBS emulation hook Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: factor out EL1 SSBS emulation hook" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 09/15] arm64: factor insn read out of call_undef_hook() Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: factor insn read out of call_undef_hook()" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 10/15] arm64: rework EL0 MRS emulation Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: rework EL0 MRS emulation" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 11/15] arm64: armv8_deprecated: fold ops into insn_emulation Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: armv8_deprecated: fold ops into insn_emulation" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 12/15] arm64: armv8_deprecated move emulation functions Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: armv8_deprecated move emulation functions" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 13/15] arm64: armv8_deprecated: move aarch32 helper earlier Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: armv8_deprecated: move aarch32 helper earlier" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 14/15] arm64: armv8_deprecated: rework deprected instruction handling Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: armv8_deprecated: rework deprected instruction handling" has been added to the 5.10-stable tree gregkh
2023-10-11 10:05 ` [PATCH v5.10 RESEND 15/15] arm64: armv8_deprecated: fix unused-function error Jinjie Ruan
2023-10-16 8:02 ` Patch "arm64: armv8_deprecated: fix unused-function error" has been added to the 5.10-stable tree gregkh
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=2023101625-qualifier-ahead-11d5@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=ebiederm@xmission.com \
--cc=f.fainelli@gmail.com \
--cc=haibinzhang@tencent.com \
--cc=hewenliang4@huawei.com \
--cc=james.morse@arm.com \
--cc=joey.gouly@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=peterz@infradead.org \
--cc=ruanjinjie@huawei.com \
--cc=sashal@kernel.org \
--cc=scott@os.amperecomputing.com \
--cc=stable-commits@vger.kernel.org \
--cc=stable@kernel.org \
--cc=will@kernel.org \
--cc=youngmin.nam@samsung.com \
--cc=yuzenghui@huawei.com \
/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).