entry: Remove empty addr_limit_user_check()
authorMark Rutland <mark.rutland@arm.com>
Mon, 21 Aug 2023 16:35:26 +0000 (17:35 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 23 Aug 2023 08:32:39 +0000 (10:32 +0200)
Back when set_fs() was a generic API for altering the address limit,
addr_limit_user_check() was a safety measure to prevent userspace being
able to issue syscalls with an unbound limit.

With the the removal of set_fs() as a generic API, the last user of
addr_limit_user_check() was removed in commit:

  b5a5a01d8e9a44ec ("arm64: uaccess: remove addr_limit_user_check()")

... as since that commit, no architecture defines TIF_FSCHECK, and hence
addr_limit_user_check() always expands to nothing.

Remove addr_limit_user_check(), updating the comment in
exit_to_user_mode_prepare() to no longer refer to it. At the same time,
the comment is reworded to be a little more generic so as to cover
kmap_assert_nomap() in addition to lockdep_sys_exit().

No functional change.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230821163526.2319443-1-mark.rutland@arm.com
include/linux/syscalls.h
kernel/entry/common.c

index 03e3d0121d5e3eb7498a245265d3ce8d76667a53..c4b9b66b0d053ebea11fbd0ad8fbffd5520a5407 100644 (file)
@@ -283,22 +283,6 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
 #define SYSCALL32_DEFINE6 SYSCALL_DEFINE6
 #endif
 
-/*
- * Called before coming back to user-mode. Returning to user-mode with an
- * address limit different than USER_DS can allow to overwrite kernel memory.
- */
-static inline void addr_limit_user_check(void)
-{
-#ifdef TIF_FSCHECK
-       if (!test_thread_flag(TIF_FSCHECK))
-               return;
-#endif
-
-#ifdef TIF_FSCHECK
-       clear_thread_flag(TIF_FSCHECK);
-#endif
-}
-
 /*
  * These syscall function prototypes are kept in the same order as
  * include/uapi/asm-generic/unistd.h. Architecture specific entries go below,
index be61332c66b54a02b37d7a1847001b23a82d910e..d7ee4bc3f2ba3e6d7a8d5976952e646430d46648 100644 (file)
@@ -205,8 +205,7 @@ static void exit_to_user_mode_prepare(struct pt_regs *regs)
 
        arch_exit_to_user_mode_prepare(regs, ti_work);
 
-       /* Ensure that the address limit is intact and no locks are held */
-       addr_limit_user_check();
+       /* Ensure that kernel state is sane for a return to userspace */
        kmap_assert_nomap();
        lockdep_assert_irqs_disabled();
        lockdep_sys_exit();