From patchwork Wed Feb 8 18:35:09 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: 54571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3621001wrn; Wed, 8 Feb 2023 10:40:31 -0800 (PST) X-Google-Smtp-Source: AK7set9S8a2yUbwipgUIiKbv3KczCMqXPBEArLzx1V3zxUU3NOSBfbCtF+ctyCrWnPOCsKrDqpU3 X-Received: by 2002:a05:6a20:8e29:b0:b6:5687:17b1 with SMTP id y41-20020a056a208e2900b000b6568717b1mr9657939pzj.4.1675881630993; Wed, 08 Feb 2023 10:40:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675881630; cv=none; d=google.com; s=arc-20160816; b=1D+VroxQtoUo8x+A0e7b3//6m8mLgPjZiPjLGfDLzpkEcZwNXxXQcue0Yw67YGxUQM O9QMrAqHYh9S93AjT9coPsuCtL73LsvbOylGiH2u0lMi1dGuKX7N8br7qWUD85/GQYyG c3NBHsLti6JWcgZx5jfAAFtHOQUv3pKsnXIpNCVyfkvNByzb0zMqbk7kWH8xM7xxyDvt pcWO5jxt/kzcF5Q+DFKV8GdSH8pxFchr2KamfYVkh7L1oC5eVGyVQ82JakFge8f913TT xEKJmh/J1AQ+HFgdFHhV8SEQYMqAMfS0O1UluZ4dF2oigH20QiwDMDMMDDlYR1gUkXTd eorA== 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=pcFjdWbs2XTopyqPClTl+dUkRc1UPDvqjqiKoje/Vj0=; b=vXhijkArwXyb5KIxM9KKEbTvf8nMYQl+xVE5eWfBBdolFykvxDm87/PnFrugVESwNu Z+MpEKhTKeK93SyYnD8Hp5/4iah6XcCgxO6KXyk6a+wns/ZVIlfwNdFPcnEOjyINPQ7K rUZZWAJ0293yAedmi2xEurDBqPOW7WbcfbS5mICwB5aK5wunM18bqBPSIQg7t33jXvlp VDlDl03t8oqb9uZn+nar3vTczwff6gKdYF39vx9Rcdkha987dMU/PdY/m+tnMcZlJMdg elCIDmRy0LZ1hIXFV+hq0hppOJ8Kmlo8C1u04rvhm67uq7XbUIRZtNTvKZg28Uktuvw/ TxTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0k14qGeZ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 q13-20020a63750d000000b004eba7eca1a2si17664427pgc.248.2023.02.08.10.40.17; Wed, 08 Feb 2023 10:40:30 -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=0k14qGeZ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S232006AbjBHSfm (ORCPT + 99 others); Wed, 8 Feb 2023 13:35:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231935AbjBHSf2 (ORCPT ); Wed, 8 Feb 2023 13:35:28 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B343956498; Wed, 8 Feb 2023 10:35:11 -0800 (PST) Date: Wed, 08 Feb 2023 18:35:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1675881310; 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=pcFjdWbs2XTopyqPClTl+dUkRc1UPDvqjqiKoje/Vj0=; b=0k14qGeZfdPHaKnLiQkIzZywhiJOcfCacHEP3/Ouw2a0/nMtiOv2nKM7C6uHNHaOeEpS9N heSuWH01fuNJWwJsvrfiWE/4MBk39yBB8GXJYtNELLjU0k1DwTFZ8ctwvEaO25h0+zDG5t SW1a0PLaBQkGJLXwWOSBjOMc1pNrgNhWV4GkC3cmzWokGh7nKXOJ5IWkXWvVQvt4lAvO5p Aj2e3r0iE3vvGeO/LqxiXzkvAlOOgvRi9QXgTQqUMLG+xjTUlaQLyY+9GJ8KQEwMZFHBI2 x9QlDkBP2PLJhVJtK23+z3F09wGPgSOVReoQL3sEmzMPSfgLDe/AyWTcAgOGQA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1675881310; 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=pcFjdWbs2XTopyqPClTl+dUkRc1UPDvqjqiKoje/Vj0=; b=y0koWMrDq72sbcPZGIHF4ZqwVgbr8UQ5eAzfJz1dHj/xkirFyUQD+EGq5izg3AOSNFzfBn F1RtiXBK+wvY7DDw== 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 , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <167588130939.4906.8140947496160437703.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?1757289257324283184?= The following commit has been merged into the x86/urgent branch of tip: Commit-ID: bd467ddd80ab3ecdd846ac148274603e1214ae73 Gitweb: https://git.kernel.org/tip/bd467ddd80ab3ecdd846ac148274603e1214ae73 Author: Nadav Amit AuthorDate: Wed, 08 Feb 2023 07:17:08 Committer: Dave Hansen CommitterDate: Wed, 08 Feb 2023 08:26:21 -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 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];