From patchwork Mon Sep 18 07:30:23 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: 141303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2508529vqi; Mon, 18 Sep 2023 01:35:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZUcDo/j+re3DEqSMTPdgLsTffqqOWp2w8u+j0EPjrHviGzyZ1mOt7kp9kzG6xoIZGuS7z X-Received: by 2002:a05:6a00:1488:b0:68f:dfda:182a with SMTP id v8-20020a056a00148800b0068fdfda182amr8990743pfu.26.1695026112343; Mon, 18 Sep 2023 01:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695026112; cv=none; d=google.com; s=arc-20160816; b=eJkFwPJjaHpCNrRGdAXLONFgJWOCZC64amCAXILF9Dkr+HlIqfRjOFgMi+vkwYfyCv r4GJINsMI/+92b95mKCuMHoxfJ0oXLZAmBl5GPoGaKUFwZmoKZOmNdeqE2KC7V7dUsAh VCOfsjvxn06zBDWh1JTr61q6kkPNUVe2uqwjrw39hsdSOH53iu8cumRGYCUFd2Wkxr+k 7qxnlEanFmptIq0tS4M+JzCwkQRXuuAj73vlS+K3CkfYjZwDT/wkWIQ8IuhjY4h+unwe TSwovcnfHj1ZYXwbfz/9KGFU62zCJQnWx5jG4SeLetLZ8BlaDIi0yYWFMn4PLiM/Gyvm 5E8A== 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:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=8wZ4UPauAaCMdYEQufzFfL5YyIzdQq3MPR1r1SVgLl4=; fh=pEbi4kn0pwmSwzj9QwBPh+tdpDZ03TJTQeWxqIrfn7M=; b=G0iFOj4xk92IKFIHRoz3nncwQQlmFAtTRG9CvNXBs6mEZvcJ2DP0CqDbZElHZo3QA6 Nfy5Bc/gL3fdItQPDQus7aM4OSTq4E8qOOaRDZgUXRw6XZ3DKkBbeDGnxuK/v9PF8Hyu TwNcZHTLs7aPAwCWyPAqVdPPylYEUjRq9RhzUUD9BZzgAZIrf/MYFYmnnk0F1EOBTtb8 P/DDP3s+AWcbkhLMTkBdEYgnlhlvGMfJ8QRkVYrkWH2DYfMQ77jHnrAAsAqStkOry3ik KN9VzMMLwujUuLz9qI/pHAPXRnpolHnPl1AFhfRaGNYR6ipsRD5haGJq8UeEPKdMxyIx oOeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="gV/7wnWM"; dkim=neutral (no key) header.i=@linutronix.de header.b=iA2tcvBE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id bt10-20020a056a00438a00b0068e4358d041si7650519pfb.175.2023.09.18.01.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 01:35:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="gV/7wnWM"; dkim=neutral (no key) header.i=@linutronix.de header.b=iA2tcvBE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D8DA38093720; Mon, 18 Sep 2023 00:32:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240211AbjIRHbY (ORCPT + 27 others); Mon, 18 Sep 2023 03:31:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240087AbjIRHao (ORCPT ); Mon, 18 Sep 2023 03:30:44 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3F5F1B6; Mon, 18 Sep 2023 00:30:27 -0700 (PDT) Date: Mon, 18 Sep 2023 07:30:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695022224; 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: in-reply-to:in-reply-to:references:references; bh=8wZ4UPauAaCMdYEQufzFfL5YyIzdQq3MPR1r1SVgLl4=; b=gV/7wnWMOU4lraE4apiIHUPDL076zPdl9OfBQoA9MntDwti5ono38fOBi+TrsI/1pD0aVq kjHUJvgwawQVxlu1OqATleJ72C8+0W2onarbYb/eF6zn5685jHC+IZydA9IOZRrwxDFovr fAiGvDFhg+5YjlY/lbAh1Jj7YLuU0Bx3cXRwptgL71m+zHjogXhNBr/pnG3AVXKYJzCtsj eQ22XJogsuDfPu/KIw7GfshqIN1WPf5ldqFyUUxfELMvAQrOFAsXJNZ5+/z8sN9+UgY2jO pziHU5tiyvv2NndWcrjaIgasZX3DQZJsGR00Ho6oZexo12lN8UNVGPpdOdCYvg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695022224; 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: in-reply-to:in-reply-to:references:references; bh=8wZ4UPauAaCMdYEQufzFfL5YyIzdQq3MPR1r1SVgLl4=; b=iA2tcvBEKMxygXC/IF3zAffUqKuhwbR3zGwMVgy51He8e8GkMRGFyaBAPiymmKLtf5W0lT HOacWn4X/QByo7AQ== From: "tip-bot2 for Rik van Riel" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/mm, kexec, ima: Use memblock_free_late() from ima_free_kexec_buffer() Cc: Mike Rappoport , Rik van Riel , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230817135558.67274c83@imladris.surriel.com> References: <20230817135558.67274c83@imladris.surriel.com> MIME-Version: 1.0 Message-ID: <169502222333.27769.4548051138666245264.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 00:32:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777363700695794345 X-GMAIL-MSGID: 1777363700695794345 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 34cf99c250d5cd2530b93a57b0de31d3aaf8685b Gitweb: https://git.kernel.org/tip/34cf99c250d5cd2530b93a57b0de31d3aaf8685b Author: Rik van Riel AuthorDate: Thu, 17 Aug 2023 13:55:58 -04:00 Committer: Ingo Molnar CommitterDate: Mon, 18 Sep 2023 09:24:15 +02:00 x86/mm, kexec, ima: Use memblock_free_late() from ima_free_kexec_buffer() The code calling ima_free_kexec_buffer() runs long after the memblock allocator has already been torn down, potentially resulting in a use after free in memblock_isolate_range(). With KASAN or KFENCE, this use after free will result in a BUG from the idle task, and a subsequent kernel panic. Switch ima_free_kexec_buffer() over to memblock_free_late() to avoid that bug. Fixes: fee3ff99bc67 ("powerpc: Move arch independent ima kexec functions to drivers/of/kexec.c") Suggested-by: Mike Rappoport Signed-off-by: Rik van Riel Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20230817135558.67274c83@imladris.surriel.com --- arch/x86/kernel/setup.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index b9145a6..b098b1f 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -358,15 +358,11 @@ static void __init add_early_ima_buffer(u64 phys_addr) #if defined(CONFIG_HAVE_IMA_KEXEC) && !defined(CONFIG_OF_FLATTREE) int __init ima_free_kexec_buffer(void) { - int rc; - if (!ima_kexec_buffer_size) return -ENOENT; - rc = memblock_phys_free(ima_kexec_buffer_phys, - ima_kexec_buffer_size); - if (rc) - return rc; + memblock_free_late(ima_kexec_buffer_phys, + ima_kexec_buffer_size); ima_kexec_buffer_phys = 0; ima_kexec_buffer_size = 0;