arm64/syscalls: Move address limit check in loop
authorThomas Garnier <[email protected]>
Thu, 7 Sep 2017 15:30:47 +0000 (08:30 -0700)
committerThomas Gleixner <[email protected]>
Sun, 17 Sep 2017 17:45:33 +0000 (19:45 +0200)
A bug was reported on ARM where set_fs might be called after it was
checked on the work pending function. ARM64 is not affected by this bug
but has a similar construct. In order to avoid any similar problems in
the future, the addr_limit_user_check function is moved at the beginning
of the loop.

Fixes: cf7de27ab351 ("arm64/syscalls: Check address limit on user-mode return")
Reported-by: Leonard Crestez <[email protected]>
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]
arch/arm64/kernel/signal.c

index c45214f8fb5497fdaed8665b8b066bbfc0118ed2..0bdc96c61bc0f2b14f627142a2778409c9c6a7d0 100644 (file)
@@ -751,10 +751,10 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
         */
        trace_hardirqs_off();
 
-       /* Check valid user FS if needed */
-       addr_limit_user_check();
-
        do {
+               /* Check valid user FS if needed */
+               addr_limit_user_check();
+
                if (thread_flags & _TIF_NEED_RESCHED) {
                        schedule();
                } else {