Commit ab1e29ac authored by Eric Chan's avatar Eric Chan Committed by Catalin Marinas

arm64: lockdep: enable checks for held locks when returning to userspace

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: default avatarEric Chan <ericchancf@google.com>
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20230531090909.357047-1-ericchancf@google.comSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 56b77ba1
...@@ -126,7 +126,7 @@ static __always_inline void __exit_to_user_mode(void) ...@@ -126,7 +126,7 @@ static __always_inline void __exit_to_user_mode(void)
lockdep_hardirqs_on(CALLER_ADDR0); 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; unsigned long flags;
...@@ -135,11 +135,13 @@ static __always_inline void prepare_exit_to_user_mode(struct pt_regs *regs) ...@@ -135,11 +135,13 @@ static __always_inline void prepare_exit_to_user_mode(struct pt_regs *regs)
flags = read_thread_flags(); flags = read_thread_flags();
if (unlikely(flags & _TIF_WORK_MASK)) if (unlikely(flags & _TIF_WORK_MASK))
do_notify_resume(regs, flags); do_notify_resume(regs, flags);
lockdep_sys_exit();
} }
static __always_inline void exit_to_user_mode(struct pt_regs *regs) 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(); mte_check_tfsr_exit();
__exit_to_user_mode(); __exit_to_user_mode();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment