OSDN Git Service

x86/optprobe: Fix OPTPROBE vs UACCESS
authorPeter Zijlstra <peterz@infradead.org>
Thu, 5 Mar 2020 09:21:30 +0000 (10:21 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 20 Mar 2020 12:06:22 +0000 (13:06 +0100)
commitd8a738689794c42c3844284b99ddf165d10a724e
treefe08aebdea08225ef9c23a99fb87401169261c76
parentd1c9f7d117195da6229408d31d01ee011425fc68
x86/optprobe: Fix OPTPROBE vs UACCESS

While looking at an objtool UACCESS warning, it suddenly occurred to me
that it is entirely possible to have an OPTPROBE right in the middle of
an UACCESS region.

In this case we must of course clear FLAGS.AC while running the KPROBE.
Luckily the trampoline already saves/restores [ER]FLAGS, so all we need
to do is inject a CLAC. Unfortunately we cannot use ALTERNATIVE() in the
trampoline text, so we have to frob that manually.

Fixes: ca0bbc70f147 ("sched/x86_64: Don't save flags on context switch")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://lkml.kernel.org/r/20200305092130.GU2596@hirez.programming.kicks-ass.net
arch/x86/include/asm/kprobes.h
arch/x86/kernel/kprobes/opt.c