Skip to content

Commit ab1e29a

Browse files
ericchancfctmarinas
authored andcommitted
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: Eric Chan <[email protected]> Acked-by: Mark Rutland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 56b77ba commit ab1e29a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/arm64/kernel/entry-common.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static __always_inline void __exit_to_user_mode(void)
126126
lockdep_hardirqs_on(CALLER_ADDR0);
127127
}
128128

129-
static __always_inline void prepare_exit_to_user_mode(struct pt_regs *regs)
129+
static __always_inline void exit_to_user_mode_prepare(struct pt_regs *regs)
130130
{
131131
unsigned long flags;
132132

@@ -135,11 +135,13 @@ static __always_inline void prepare_exit_to_user_mode(struct pt_regs *regs)
135135
flags = read_thread_flags();
136136
if (unlikely(flags & _TIF_WORK_MASK))
137137
do_notify_resume(regs, flags);
138+
139+
lockdep_sys_exit();
138140
}
139141

140142
static __always_inline void exit_to_user_mode(struct pt_regs *regs)
141143
{
142-
prepare_exit_to_user_mode(regs);
144+
exit_to_user_mode_prepare(regs);
143145
mte_check_tfsr_exit();
144146
__exit_to_user_mode();
145147
}

0 commit comments

Comments
 (0)