From patchwork Thu Dec 1 14:26:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 28411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp302519wrr; Thu, 1 Dec 2022 06:50:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf5QOjaV4N3KLLPomzOtbF60vDpTdaaIzrfkejr5fL7LIeav0NcSlw7DANBHUKyyPczOF/iT X-Received: by 2002:a17:906:124d:b0:7ad:b822:d2e4 with SMTP id u13-20020a170906124d00b007adb822d2e4mr56248938eja.35.1669906206892; Thu, 01 Dec 2022 06:50:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669906206; cv=none; d=google.com; s=arc-20160816; b=VVO7Y3fHlqAKvTIWd6NesYxyUO7ow/Ou8hul0KWUqWu5jMvhTY56FPyVor3nvHAqPN j58llUipQWNLVbzSPGbVo8vltad4NJ+UVY+oSAbsJh9VIHNLdOkFAAkIJR6QQPmpSQYk SE4NRBc+1e5L4LveeiJV5mLq2rhf6dSZ+EtnwflUPrNflEYGh+ihUaFfcw5nt7hMThg1 xE8H328m3imEkQe9fpAwS5lUxFLtH9+twjiPjnJAwna829VqyBgeefdPyFbi3nf9aHrg EbGLWRJpuFWQclWJf8zApF5b2Az+jrFSUSApvDQxuSay0lQMm0a22bbUDgMN0d9FPWpB iuCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=+dnLI4LC6eJgJxf7sHC6b0Dpc13wWosQCy3Z8sjl1q8=; b=LMwD1mWVsrqTnlt8Z1vgSbcwvilUgAfh4rDnXd6zgONbWqJ8Rn1nOoDnxhFIMY9+YD tQeuIKro4pdfMD5m/m2G2CTnhuiPBySM3s9mtetFPJBpJyLS/IUynmFlOS4u2K36EZs6 m6WPLvE3VcLp4Nh/eqs8SQ10YTZp9Ch8Dc6cknOpr+NmTsAvgM2ZwJrFVti86tHEBkW1 +YxvEp2DTp8NgtlPQAiAtcPd8Ft4/Fj0eLSX8oO45vobH/YvkECGOlhJA/rdwZ3FXggA HNYuQOljcEu1VPItXMOlQuCO+jWHKe0qO0KxW3JH9meFq2jYazSIh6Q7VQwIt2ccFg82 CfKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="g8FmWw/P"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb40-20020a1709076da800b007bebf105450si4360317ejc.235.2022.12.01.06.49.39; Thu, 01 Dec 2022 06:50:06 -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="g8FmWw/P"; 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 S231540AbiLAO1w (ORCPT + 99 others); Thu, 1 Dec 2022 09:27:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229968AbiLAO1u (ORCPT ); Thu, 1 Dec 2022 09:27:50 -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 24D9C1F2DE for ; Thu, 1 Dec 2022 06:26:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669904811; 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; bh=+dnLI4LC6eJgJxf7sHC6b0Dpc13wWosQCy3Z8sjl1q8=; b=g8FmWw/PUxFl/LezhaPNMTMWKkkzRYh9Lzx9flo4b6wzlQcrLju5uEf4hUnSVEbM7hscj+ erEgUk4hSZvv6cOStGLglf50rCBtMzo2tCkIirTJAhoL4gbEpPi+G8cvwgpDLQd2Dk6IEv fRqyTN958BtMEwp+yls+gwn+veerNSk= 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-351-D7-L7xyyPcu9OwdViQLV7w-1; Thu, 01 Dec 2022 09:26:49 -0500 X-MC-Unique: D7-L7xyyPcu9OwdViQLV7w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A875A185A7A3; Thu, 1 Dec 2022 14:26:48 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (ovpn-192-172.brq.redhat.com [10.40.192.172]) by smtp.corp.redhat.com (Postfix) with SMTP id D42E4111E3F8; Thu, 1 Dec 2022 14:26:46 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 1 Dec 2022 15:26:47 +0100 (CET) Date: Thu, 1 Dec 2022 15:26:44 +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] uprobes/x86: allow to probe a "nop" insn with 0x66 prefix Message-ID: <20221201142644.GA27185@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751023570642956603?= X-GMAIL-MSGID: =?utf-8?q?1751023570642956603?= From: Denys Vlasenko 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 Signed-off-by: Oleg Nesterov Acked-by: Masami Hiramatsu (Google) --- 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;