chengshan / rpms / kernel

Forked from rpms/kernel 2 years ago
Clone
b37f23
diff -up linux-3.10.0-327.sdl7.x86_64/arch/x86/include/asm/ptrace.h.addmissing linux-3.10.0-327.sdl7.x86_64/arch/x86/include/asm/ptrace.h
b37f23
--- linux-3.10.0-327.sdl7.x86_64/arch/x86/include/asm/ptrace.h.addmissing	2015-10-29 16:56:51.000000000 -0400
b37f23
+++ linux-3.10.0-327.sdl7.x86_64/arch/x86/include/asm/ptrace.h	2015-11-21 23:33:16.430036291 -0500
b37f23
@@ -109,6 +109,23 @@ static inline int user_mode_vm(struct pt
b37f23
 #endif
b37f23
 }
b37f23
 
b37f23
+/*
b37f23
+ * This is the fastest way to check whether regs come from user space.
b37f23
+ * It is unsafe if regs might come from vm86 mode, though -- in vm86
b37f23
+ * mode, all bits of CS and SS are completely under the user's control.
b37f23
+ * The CPU considers vm86 mode to be CPL 3 regardless of CS and SS.
b37f23
+ *
b37f23
+ * Do NOT use this function unless you have already ruled out the
b37f23
+ * possibility that regs came from vm86 mode.
b37f23
+ *
b37f23
+ * We check for RPL != 0 instead of RPL == 3 because we don't use rings
b37f23
+ * 1 or 2 and this is more efficient.
b37f23
+ */
b37f23
+static inline int user_mode_ignore_vm86(struct pt_regs *regs)
b37f23
+{
b37f23
+	return (regs->cs & SEGMENT_RPL_MASK) != 0;
b37f23
+}
b37f23
+
b37f23
 static inline int v8086_mode(struct pt_regs *regs)
b37f23
 {
b37f23
 #ifdef CONFIG_X86_32