Skip to content

Commit bf29ed1

Browse files
thgarnieKAGA-KOKO
authored andcommitted
syscalls: Use CHECK_DATA_CORRUPTION for addr_limit_user_check
Use CHECK_DATA_CORRUPTION instead of BUG_ON to provide more flexibility on address limit failures. By default, send a SIGKILL signal to kill the current process preventing exploitation of a bad address limit. Make the TIF_FSCHECK flag optional so ARM can use this function. Signed-off-by: Thomas Garnier <[email protected]> Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Pratyush Anand <[email protected]> Cc: Dave Martin <[email protected]> Cc: Will Drewry <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Cc: Russell King <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: David Howells <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Al Viro <[email protected]> Cc: [email protected] Cc: Yonghong Song <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected]
1 parent 0666f56 commit bf29ed1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

include/linux/syscalls.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,21 +221,25 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
221221
} \
222222
static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
223223

224-
#ifdef TIF_FSCHECK
225224
/*
226225
* Called before coming back to user-mode. Returning to user-mode with an
227226
* address limit different than USER_DS can allow to overwrite kernel memory.
228227
*/
229228
static inline void addr_limit_user_check(void)
230229
{
231-
230+
#ifdef TIF_FSCHECK
232231
if (!test_thread_flag(TIF_FSCHECK))
233232
return;
233+
#endif
234234

235-
BUG_ON(!segment_eq(get_fs(), USER_DS));
235+
if (CHECK_DATA_CORRUPTION(!segment_eq(get_fs(), USER_DS),
236+
"Invalid address limit on user-mode return"))
237+
force_sig(SIGKILL, current);
238+
239+
#ifdef TIF_FSCHECK
236240
clear_thread_flag(TIF_FSCHECK);
237-
}
238241
#endif
242+
}
239243

240244
asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special,
241245
qid_t id, void __user *addr);

0 commit comments

Comments
 (0)