Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4919166rwb; Sun, 4 Dec 2022 10:32:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf5G01hdU/2Tg8oosh2LbINeu2vbuCLFCDlASAJSxQeJi3SKv/6uJOnUDi3wdOicMbhMvrwX X-Received: by 2002:a05:6402:120c:b0:46b:86:20b5 with SMTP id c12-20020a056402120c00b0046b008620b5mr31997700edw.130.1670178724918; Sun, 04 Dec 2022 10:32:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670178724; cv=none; d=google.com; s=arc-20160816; b=Cs2Qw1uz5ojPesGNtoCxowWs9NJLDb5WJkEbFp0JhY7EQYFZISylygpYwtmeouGk69 dQY1b4sqAyxaYL5MydkgsWmPoXHJHI1WxfHmZJsjI9ZTuh1oeJK9dlPIkCvqwZYDeIYP 5tiv6YappqtFXK5VStKWBIrb+zXwNiIIFOFzkNqTHLmyNOKXAAmRHr/ePYTOmP4GU5Mh xDzKY6NUbGr8/Koy9eXUekXhnBGQmw4DO1bxbCDnlpPIT+Y+/TjADBviotUjoosYG+FH 37tWm7MuCWtrBcOWdbYZTVWCICHXNuH1Ukq8JOySkS0P72IUinjA7e6AWIkCvN4bbN7s OShg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=RajNx5uZrgPrmrxQ2H0N99C4eBcKtsC5+ag0wdpHdLI=; b=idi35XYgJp6e+SWqksFKwkvvRK0HUz6Bp1MdKK1rrJQcX+QR00BND8q+YuHCjpPqzs Oayvlphj5O/OrVf5KwnxS76oQHBxemb5oN7teaf17EaCZr27RIAZmbB2dYd933uBpQOp fWndzZaonZCP4oVCtkjLZXMVBAl/68XJKTkrdNc3TqvNSSpAFWAoH26XXg5n62D/wT8c 3a8CJrr/3VIfcA2wnfSNHPo2imMcBxlVmMBJjf4rwJyY+ogG90rnM1EjkuUGhorZBIG4 q22TTnNYw/5e88eH/BAZ4c0d3h0VW/pmDCst8vw+X8pEbEwObq3au3eqRVrbga3W1Z/0 CYiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R5wjBFgH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd33-20020a1709076e2100b0078316f0b5f8si10440776ejc.88.2022.12.04.10.31.45; Sun, 04 Dec 2022 10:32:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R5wjBFgH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230200AbiLDRkg (ORCPT + 82 others); Sun, 4 Dec 2022 12:40:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229999AbiLDRkf (ORCPT ); Sun, 4 Dec 2022 12:40:35 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7753D13F79 for ; Sun, 4 Dec 2022 09:39:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670175580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RajNx5uZrgPrmrxQ2H0N99C4eBcKtsC5+ag0wdpHdLI=; b=R5wjBFgH4jRlbAQemUTn4yzvKKLP3fLS/96/rA0ahiH3JILEThCEB6rBlKp5sJ36snrAVa H36pw11hz4x5PiZY/bP/IojMH3YkMR+99H3FYQZfPB4nDigwdnyzfrGZYc5efBgaV4uIw+ xw57ePi7F+kygEE3Z/o+sppVY1AUiU8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-111-Yu-DpvUPM86mxxzvttV8dQ-1; Sun, 04 Dec 2022 12:39:37 -0500 X-MC-Unique: Yu-DpvUPM86mxxzvttV8dQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C7886101A54E; Sun, 4 Dec 2022 17:39:36 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (ovpn-192-89.brq.redhat.com [10.40.192.89]) by smtp.corp.redhat.com (Postfix) with SMTP id E9ABA40C83DC; Sun, 4 Dec 2022 17:39:34 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 4 Dec 2022 18:39:36 +0100 (CET) Date: Sun, 4 Dec 2022 18:39:33 +0100 From: Oleg Nesterov To: Andrew Morton , Masami Hiramatsu , Thomas Gleixner Cc: Denys Vlasenko , Seiji Nishikawa , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] uprobes/x86: allow to probe a "nop" insn with 0x66 prefix Message-ID: <20221204173933.GA31544@redhat.com> References: <20221201142644.GA27185@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221201142644.GA27185@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Intel icc -hotpatch inserts 2-byte "0x66 0x90" NOP at the start of each function to reserve extra space for hot-patching, and currently it is not possible to probe these functions because branch_setup_xol_ops() wrongly nacks NOP with REP prefix. Fixes: 250bbd12c2fe ("uprobes/x86: Refuse to attach uprobe to "word-sized" branch insns") Reported-by: Seiji Nishikawa Suggested-by: Denys Vlasenko Acked-by: Masami Hiramatsu (Google) Signed-off-by: Oleg Nesterov --- arch/x86/kernel/uprobes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index b63cf8f7745e..6c07f6daaa22 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -722,8 +722,9 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) switch (opc1) { case 0xeb: /* jmp 8 */ case 0xe9: /* jmp 32 */ - case 0x90: /* prefix* + nop; same as jmp with .offs = 0 */ break; + case 0x90: /* prefix* + nop; same as jmp with .offs = 0 */ + goto setup; case 0xe8: /* call relative */ branch_clear_offset(auprobe, insn); @@ -753,6 +754,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) return -ENOTSUPP; } +setup: auprobe->branch.opc1 = opc1; auprobe->branch.ilen = insn->length; auprobe->branch.offs = insn->immediate.value; -- 2.25.1.362.g51ebf55