Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp58054pja; Fri, 22 Nov 2019 03:25:17 -0800 (PST) X-Google-Smtp-Source: APXvYqzXsEcCjNPCRazty5j/5jt1yXl/9GKewQ8kf9jucebHj2vpv4c7o34eWXrfP4iOw7oowaKf X-Received: by 2002:a17:906:af5a:: with SMTP id ly26mr21963579ejb.252.1574421917528; Fri, 22 Nov 2019 03:25:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574421917; cv=none; d=google.com; s=arc-20160816; b=KiXA2PXX0MZSMZ6wKZOXMJIm7LDr2Pc6uKnG5ySglKjemqzTch6LF7cT5jzXUXEATR U0oRoY64DdWC4HyjeGRaSRR10l2ubKqJwacSbzD1lNtlTAKi1vlmMyMNmvn7GQEWTX0s r/J/PBBvXhpOrWlKSnAu4mN+YGpBO/QKa+x1zDyIa+MG2+OVDkqihOQTTlyPpVamYs4e q9T0tVPNHu2ks+3dC7HWgBy74L9UuI9yhxg/FKhA8rbVUB5StLVvA9WmfbW8YBmjrUlH /s69F9OPo+pttsujdDfpyAl0lrE1kiRjv8lQ+3Qp+JyZAfs0cksvlreSN/1tajOKpID0 fL6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B+Enc84STJnIkJGJNx1P85cbqxGdzEDr4bfMtjIYXSg=; b=DrzJ2aD7lKMT0mF6I54DXr5Jgg68GShFODIS1yiQcQSp6CfxE9cNgyJ1kZofFRBCwu jeO+rdREyX2zBTdOL9X6CmWQGPVl8fybrrwtV6RYkPsOsTl0WA7ZbE5C/c0s2EZH9DUa t+85uaZWCv/MYd5F9S10g7h6wHrqnBGDMkGGCEMnDK++u8+c4kiMsv6yyJxzsbJzRGfA RUAoeCMtnA2U37/N8YbkWPg0tPsRfRpzi9o6MUEjAUu5sURmPiTCE7pKDM4yNPtNZyaA vR71PiEgjUJNLmDGRPbz3wYMu5j2Eu3t9eY1wi879FLBCMuUAgJiGBE88J4HHIdgCsWK 5zqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w86Fkkep; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ca10si4347307edb.67.2019.11.22.03.24.53; Fri, 22 Nov 2019 03:25:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w86Fkkep; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729289AbfKVLUY (ORCPT + 99 others); Fri, 22 Nov 2019 06:20:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:52672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729567AbfKVKp4 (ORCPT ); Fri, 22 Nov 2019 05:45:56 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6795D20721; Fri, 22 Nov 2019 10:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574419555; bh=DuCIBAqhdSOob/5HkZMdAhgQxPJHm9GEVLYGMGLpj1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w86FkkepnUtIBAUAgCBRxNY02ieV6Ea3Ps404fGEqBe/QyjZIGvlKSrQ6Z83l4OW6 /osV3H1M6069vz8af7jlBkuRh3LhJGAdvq7DMHyRZmdlFIZOIHjU9eH9ldAYVuoGdL pTHmJADWKKXgLDVve7CodShmswvULIqsont5JStw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Thomas Gleixner , Oleg Nesterov , Ricardo Neri , Francis Deslauriers , Alexei Starovoitov , Steven Rostedt , Andy Lutomirski , "H . Peter Anvin" , Yonghong Song , Borislav Petkov , Linus Torvalds , "David S . Miller" Subject: [PATCH 4.9 151/222] uprobes/x86: Prohibit probing on MOV SS instruction Date: Fri, 22 Nov 2019 11:28:11 +0100 Message-Id: <20191122100913.646743449@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100830.874290814@linuxfoundation.org> References: <20191122100830.874290814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu commit 13ebe18c94f5b0665c01ae7fad2717ae959f4212 upstream. Since MOV SS and POP SS instructions will delay the exceptions until the next instruction is executed, single-stepping on it by uprobes must be prohibited. 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 Signed-off-by: Thomas Gleixner Acked-by: Oleg Nesterov Cc: Ricardo Neri Cc: Francis Deslauriers Cc: Alexei Starovoitov Cc: Steven Rostedt Cc: Andy Lutomirski Cc: "H . Peter Anvin" Cc: Yonghong Song Cc: Borislav Petkov Cc: Linus Torvalds Cc: "David S . Miller" Link: https://lkml.kernel.org/r/152587072544.17316.5950935243917346341.stgit@devbox Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/uprobes.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -296,6 +296,10 @@ static int uprobe_init_insn(struct arch_ 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