From patchwork Wed Feb 8 20:09:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 54594 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3670878wrn; Wed, 8 Feb 2023 12:29:29 -0800 (PST) X-Google-Smtp-Source: AK7set8T313u535Ze/S50sY13n0LyiupWv2FgDEJ7BV6AOcRqAjMd5NY2+2Pzzh8qRxNUEICPgpU X-Received: by 2002:a17:90b:24f:b0:226:df9a:969c with SMTP id fz15-20020a17090b024f00b00226df9a969cmr8241844pjb.0.1675888168781; Wed, 08 Feb 2023 12:29:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675888168; cv=none; d=google.com; s=arc-20160816; b=MXaHVxCpIVtCrRbBWv7RpaSVPVX3fNOl6hs3WKsFLcrvMn0mMRLc47L3iZyrXwQz3V GZkCgd0SBBHZ5Jgv4YB3C/CSlNNXfZfGhSJYnX62umAehoejKfwNLKs2azFRAPXgc3s8 QgTlfu+g+klZlolHI8e1bBQ7a1YGL34qgSdvAJpDpu5Yet0nWA9JgJQZe1wf9tle/8FE JF0tKhH4sHLgV32u2iR0LBV6ve5lFpxxJf00geWEYFSDnV99T6BHpb78IGq3eTrCqP13 uQr+vw4oGSKGlvwAfDJy16qRVYFKQMbE5VzuU+2ftgj9ltz36ePl8i2Yk2BUzw+lPnaV addg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=7nkBggcmalQyIVcJVJzEc/6t0NOZc5Dw4snR/EDYZs4=; b=W8/k3gR09ypXhT91duqpkLNSEkUGgLtXESesOVePDESDTj5caIRUG8jcT3i32FR47A U6LgauazfWnzZB/uk0QZETB1KZE8BBspjaafrgBRIZmF3jxOBEsR3IQIIaJN1LemM9j6 bDrMJW+n3xJt+7oHXLcXumiT5kb1kqBys4bLiA1lbXGc9QxDY9q8GZjg7uO81V3UZyxK fE91MUTcSf97S/XSRna6B7uMQGRKMUkrGbV8+LCYLXzetkXqnbN8OFqHo/9Aob6pN/TZ XZqg1ijGx4T3LB903swYaNM1a305d7SNzwQ2z995oe45OnLiBid6XG1BE9/WCjNmkfjp B+Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hvFfBHd5; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f4-20020a17090ace0400b0022c4f275812si3075927pju.187.2023.02.08.12.29.12; Wed, 08 Feb 2023 12:29:28 -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=@linutronix.de header.s=2020 header.b=hvFfBHd5; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232009AbjBHUKA (ORCPT + 99 others); Wed, 8 Feb 2023 15:10:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231713AbjBHUJ6 (ORCPT ); Wed, 8 Feb 2023 15:09:58 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AB79E38C; Wed, 8 Feb 2023 12:09:57 -0800 (PST) Date: Wed, 08 Feb 2023 20:09:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1675886995; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7nkBggcmalQyIVcJVJzEc/6t0NOZc5Dw4snR/EDYZs4=; b=hvFfBHd5EGXj4RmObTGq3wkVU80wsJ57K0ukEaUITpb8STANTBvc++agklzwo/kP9no47e KOV7jIOnLzG04Heyi8BZmkISGkXAulnhSULvDp9rLwlYsY0xa+OlTr4Y7p9XEYdFTWGGKI CvvD/GU1tybLyG7ENTM/0/ggID0h1cfc7N6x0/X5pOV9N045vMXWI7y/dh3tUV5sPu2sju kIssKYn18qFVoA+3fXjlkICKqetRjYk3xH/BsM2ytCC7j6Nl5nt43m+swELZq1cDg+DvQY hvnSznkMQbWKHGtXtJwj6Nus9aWRqR46yWl5Kr3uSs8DA1x9EjcR/r8Cme5HmQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1675886995; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7nkBggcmalQyIVcJVJzEc/6t0NOZc5Dw4snR/EDYZs4=; b=anc3FzAGinGbu5ik5FBLe/mSpbNIm12otmtZkAPPy/JriWjh8cg1LAyUY1huMxR7zYXZHJ 9ZTkbwkO1K0DEOCA== From: "tip-bot2 for Nadav Amit" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/kprobes: Fix 1 byte conditional jump target Cc: "Masami Hiramatsu (Google)" , Dave Hansen , Nadav Amit , Dave Hansen , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <167588699468.4906.8001929680008508448.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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?1757289257324283184?= X-GMAIL-MSGID: =?utf-8?q?1757296112572127321?= The following commit has been merged into the x86/urgent branch of tip: Commit-ID: ae052e3ae09572194d7e574906db7272041577d3 Gitweb: https://git.kernel.org/tip/ae052e3ae09572194d7e574906db7272041577d3 Author: Nadav Amit AuthorDate: Wed, 08 Feb 2023 07:17:08 Committer: Dave Hansen CommitterDate: Wed, 08 Feb 2023 12:03:27 -08:00 x86/kprobes: Fix 1 byte conditional jump target Commit 3bc753c06dd0 ("kbuild: treat char as always unsigned") broke kprobes. Setting a probe-point on 1 byte conditional jump can cause the kernel to crash when the (signed) relative jump offset gets treated as unsigned. Fix by replacing the unsigned 'immediate.bytes' (plus a cast) with the signed 'immediate.value' when assigning to the relative jump offset. [ dhansen: clarified changelog ] Fixes: 3bc753c06dd0 ("kbuild: treat char as always unsigned") Suggested-by: Masami Hiramatsu (Google) Suggested-by: Dave Hansen Signed-off-by: Nadav Amit Signed-off-by: Dave Hansen Acked-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/all/20230208071708.4048-1-namit%40vmware.com --- arch/x86/kernel/kprobes/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index b36f3c3..695873c 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -625,7 +625,7 @@ static int prepare_emulation(struct kprobe *p, struct insn *insn) /* 1 byte conditional jump */ p->ainsn.emulate_op = kprobe_emulate_jcc; p->ainsn.jcc.type = opcode & 0xf; - p->ainsn.rel32 = *(char *)insn->immediate.bytes; + p->ainsn.rel32 = insn->immediate.value; break; case 0x0f: opcode = insn->opcode.bytes[1];