From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935018AbeEIM7M (ORCPT ); Wed, 9 May 2018 08:59:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:41636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934798AbeEIM7K (ORCPT ); Wed, 9 May 2018 08:59:10 -0400 From: Masami Hiramatsu To: x86@kernel.org, LKML , Linus Torvalds , Oleg Nesterov , Ingo Molnar Cc: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Alexei Starovoitov , Masami Hiramatsu , "David S . Miller" , Steven Rostedt , Francis Deslauriers , Ricardo Neri , Borislav Petkov , Yonghong Song Subject: [PATCH 2/2] uprobes: x86: Prohibit probing on MOV SS instruction Date: Wed, 9 May 2018 21:58:45 +0900 Message-Id: <152587072544.17316.5950935243917346341.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <152587066475.17316.3035446966107675608.stgit@devbox> References: <152587066475.17316.3035446966107675608.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since MOV SS and POP SS instructions will delay the exceptions until the next instruction is executed, we should not do single-stepping on it by uprobes. uprobe already rejects probing on POP SS (0x1f), but allows probing on MOV SS (0x8e and reg == 2). This checks the target instruction and if it is MOV SS or POP SS, returns -ENOTSUPP to reject probing. Signed-off-by: Masami Hiramatsu --- arch/x86/kernel/uprobes.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 85c7ef23d99f..c84bb5396958 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -299,6 +299,10 @@ static int uprobe_init_insn(struct arch_uprobe *auprobe, struct insn *insn, bool if (is_prefix_bad(insn)) return -ENOTSUPP; + /* We should not singlestep on the exception masking instructions */ + if (insn_masking_exception(insn)) + return -ENOTSUPP; + if (x86_64) good_insns = good_insns_64; else