* [PATCH v2] arm64: lockdep: enable checks for held locks when returning to userspace
@ 2023-05-31 9:09 Eric Chan
2023-06-06 17:30 ` Catalin Marinas
0 siblings, 1 reply; 2+ messages in thread
From: Eric Chan @ 2023-05-31 9:09 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland
Cc: Paul E . McKenney, Anshuman Khandual, Frederic Weisbecker,
Mukesh Ojha, Josh Poimboeuf, linux-arm-kernel, linux-kernel,
Eric Chan
Currently arm64 doesn't use CONFIG_GENERIC_ENTRY and doesn't call
lockdep_sys_exit() when returning to userspace.
This means that lockdep won't check for held locks when
returning to userspace, which would be useful to detect kernel bugs.
Call lockdep_sys_exit() when returning to userspace,
enabling checking for held locks.
At the same time, rename arm64's prepare_exit_to_user_mode() to
exit_to_user_mode_prepare() to more clearly align with the naming
in the generic entry code.
Signed-off-by: Eric Chan <ericchancf@google.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
---
arch/arm64/kernel/entry-common.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
index 3af3c01c93a6..9d6827201b6c 100644
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -126,7 +126,7 @@ static __always_inline void __exit_to_user_mode(void)
lockdep_hardirqs_on(CALLER_ADDR0);
}
-static __always_inline void prepare_exit_to_user_mode(struct pt_regs *regs)
+static __always_inline void exit_to_user_mode_prepare(struct pt_regs *regs)
{
unsigned long flags;
@@ -135,11 +135,13 @@ static __always_inline void prepare_exit_to_user_mode(struct pt_regs *regs)
flags = read_thread_flags();
if (unlikely(flags & _TIF_WORK_MASK))
do_notify_resume(regs, flags);
+
+ lockdep_sys_exit();
}
static __always_inline void exit_to_user_mode(struct pt_regs *regs)
{
- prepare_exit_to_user_mode(regs);
+ exit_to_user_mode_prepare(regs);
mte_check_tfsr_exit();
__exit_to_user_mode();
}
--
2.41.0.rc0.172.g3f132b7071-goog
V1 -> V2 : Revise the commit message to make it clearer and avoid any misleading information.
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] arm64: lockdep: enable checks for held locks when returning to userspace
2023-05-31 9:09 [PATCH v2] arm64: lockdep: enable checks for held locks when returning to userspace Eric Chan
@ 2023-06-06 17:30 ` Catalin Marinas
0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2023-06-06 17:30 UTC (permalink / raw)
To: Will Deacon, Mark Rutland, Eric Chan
Cc: Paul E . McKenney, Anshuman Khandual, Frederic Weisbecker,
Mukesh Ojha, Josh Poimboeuf, linux-arm-kernel, linux-kernel
On Wed, 31 May 2023 09:09:09 +0000, Eric Chan wrote:
> Currently arm64 doesn't use CONFIG_GENERIC_ENTRY and doesn't call
> lockdep_sys_exit() when returning to userspace.
> This means that lockdep won't check for held locks when
> returning to userspace, which would be useful to detect kernel bugs.
>
> Call lockdep_sys_exit() when returning to userspace,
> enabling checking for held locks.
>
> [...]
Applied to arm64 (for-next/misc), thanks!
[1/1] arm64: lockdep: enable checks for held locks when returning to userspace
https://git.kernel.org/arm64/c/ab1e29acdb33
--
Catalin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-06 17:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-31 9:09 [PATCH v2] arm64: lockdep: enable checks for held locks when returning to userspace Eric Chan
2023-06-06 17:30 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox