jianhai / rpms / kernel

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