From patchwork Wed Sep 4 11:46:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11129917 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1455514F7 for ; Wed, 4 Sep 2019 11:47:30 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E48FE20820 for ; Wed, 4 Sep 2019 11:47:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="tCvirIxs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E48FE20820 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5Tjt-00083G-En; Wed, 04 Sep 2019 11:46:17 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5Tjr-00082U-B3 for xen-devel@lists.xenproject.org; Wed, 04 Sep 2019 11:46:15 +0000 X-Inumbo-ID: 992aa230-cf09-11e9-abb0-12813bfff9fa Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 992aa230-cf09-11e9-abb0-12813bfff9fa; Wed, 04 Sep 2019 11:46:14 +0000 (UTC) Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EC0A920820; Wed, 4 Sep 2019 11:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567597574; bh=tHqEkww86KOLAmW5EQ0TIw1FCRFKi6/kyBIAI58FgmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tCvirIxsPyDLuECE+MpjKKpTgje2DwSZK2A5hmcbdQiW1cyxc+Pvk1Lo7atnCLVqd CosZL3Ic2nMvEv6WwnDL97wUaNn4N5A+Gkfebg70iepgH2JEVTQIdksucUonvRQeuo 3wD1KK8jLdHLqfGD0e+FSyAXNsQrfLCOzsdDnJDs= From: Masami Hiramatsu To: Ingo Molnar Date: Wed, 4 Sep 2019 20:46:09 +0900 Message-Id: <156759756944.24473.4664241966878257420.stgit@devnote2> X-Mailer: git-send-email 2.20.1 In-Reply-To: <156759754770.24473.11832897710080799131.stgit@devnote2> References: <156759754770.24473.11832897710080799131.stgit@devnote2> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [Xen-devel] [PATCH -tip 2/2] x86: kprobes: Prohibit probing on instruction which has Xen prefix X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Peter Zijlstra , Randy Dunlap , x86@kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Josh Poimboeuf , xen-devel@lists.xenproject.org, Boris Ostrovsky Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Prohibit probing on instruction which has XEN_EMULATE_PREFIX (it must be cpuid.) Since that prefix is a marker for Xen, if we modify the marker by kprobe's int3, that doesn't work as expected. Signed-off-by: Masami Hiramatsu --- arch/x86/kernel/kprobes/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 43fc13c831af..b1e86af4a985 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -351,6 +351,10 @@ int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn) kernel_insn_init(insn, dest, MAX_INSN_SIZE); insn_get_length(insn); + /* We can not probe XEN_EMULATE_PREFIX instruction */ + if (insn_has_xen_prefix(insn)) + return 0; + /* Another subsystem puts a breakpoint, failed to recover */ if (insn->opcode.bytes[0] == BREAKPOINT_INSTRUCTION) return 0;