From nobody Thu Sep 18 18:46:55 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B3CDC4321E for ; Sun, 4 Dec 2022 17:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230210AbiLDRkh (ORCPT ); Sun, 4 Dec 2022 12:40:37 -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-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 *aup= robe, struct insn *insn) switch (opc1) { case 0xeb: /* jmp 8 */ case 0xe9: /* jmp 32 */ - case 0x90: /* prefix* + nop; same as jmp with .offs =3D 0 */ break; + case 0x90: /* prefix* + nop; same as jmp with .offs =3D 0 */ + goto setup; =20 case 0xe8: /* call relative */ branch_clear_offset(auprobe, insn); @@ -753,6 +754,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *aup= robe, struct insn *insn) return -ENOTSUPP; } =20 +setup: auprobe->branch.opc1 =3D opc1; auprobe->branch.ilen =3D insn->length; auprobe->branch.offs =3D insn->immediate.value; --=20 2.25.1.362.g51ebf55