]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
um: Catch unprotected user memory access
authorRichard Weinberger <richard@nod.at>
Sun, 31 May 2015 17:21:51 +0000 (19:21 +0200)
committerRichard Weinberger <richard@nod.at>
Sun, 31 May 2015 17:21:51 +0000 (19:21 +0200)
If the kernel tries to access user memory without copy_from_user()
a trap will happen as kernel and userspace run in different processes
on the host side. Currently this special page fault cannot be resolved
and will happen over and over again. As result UML will lockup.
This patch allows the page fault code to detect that situation and
causes a panic() such that the root cause of the unprotected memory
access can be found and fixed.

Signed-off-by: Richard Weinberger <richard@nod.at>
arch/um/kernel/trap.c

index 8e4daf44e9805ed2380b72826a699ed139819ee3..34b633ec852f32f5d9bc5c26fa350be3822d7980 100644 (file)
@@ -219,6 +219,11 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
                show_regs(container_of(regs, struct pt_regs, regs));
                panic("Segfault with no mm");
        }
+       else if (!is_user && address < TASK_SIZE) {
+               show_regs(container_of(regs, struct pt_regs, regs));
+               panic("Kernel tried to access user memory at addr 0x%lx, ip 0x%lx",
+                      address, ip);
+       }
 
        if (SEGV_IS_FIXABLE(&fi))
                err = handle_page_fault(address, ip, is_write, is_user,