From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE1C418A6B9; Tue, 10 Sep 2024 10:24:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963857; cv=none; b=PMmHb0a8+fFmo+4/EyH1fEqDtM+s3NwpgMMzqggFq4suy4pKjASTTJRCo9PKrBlqTLsBvWYLWD2V1CQaJT+dBBIYYDcqV1JmMQqXJNZ4Yxkscy2LPMpXyT3/3MmiKrWNRdxTUdpoSxFJtsqj773AaSg/UKd0ThEwxCl9p/ZIzcI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963857; c=relaxed/simple; bh=BIEgJn+w7WVneSKFJrw0z8N/aOsQ2C+Po2n5O/wOEpY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A6NMxOd2R445yerrh6BQBMiKbbnRvm7QTxcd9IwuzqbhOLrQSz+QGzfzIzducJ/H5q110oL9Jdq3J3b+72eVLDlJyhQrpP/7ef+5lL2wC5r6s6zeoMZ+BU++daz7j6GIXjllMig1Cmdb6KdZssyqeGa22mRvj/oUaQ4Kh65w1w0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=st6L9aA0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="st6L9aA0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B9DBC4CEC3; Tue, 10 Sep 2024 10:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725963857; bh=BIEgJn+w7WVneSKFJrw0z8N/aOsQ2C+Po2n5O/wOEpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=st6L9aA0NT05f7BhzKUxsEQM4oj2rG+CZTC3ywrFUs2jsF7dsFQWK+HXtKZXvyQ67 j02oifXI0fBNaOo/Q/CBRvhKpFSR3rujvWXVPR3LeVeE5F9RBdM4SqJ6+c15MXTCWN IePWrzaCKsUoE6gE9iJviFpVBYiIl1Ry0mQdlNxY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gavin Shan , Jonathan Cameron , Catalin Marinas , Sasha Levin Subject: [PATCH 5.15 200/214] arm64: acpi: Harden get_cpu_for_acpi_id() against missing CPU entry Date: Tue, 10 Sep 2024 11:33:42 +0200 Message-ID: <20240910092606.735648428@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240910092558.714365667@linuxfoundation.org> References: <20240910092558.714365667@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jonathan Cameron [ Upstream commit 2488444274c70038eb6b686cba5f1ce48ebb9cdd ] In a review discussion of the changes to support vCPU hotplug where a check was added on the GICC being enabled if was online, it was noted that there is need to map back to the cpu and use that to index into a cpumask. As such, a valid ID is needed. If an MPIDR check fails in acpi_map_gic_cpu_interface() it is possible for the entry in cpu_madt_gicc[cpu] == NULL. This function would then cause a NULL pointer dereference. Whilst a path to trigger this has not been established, harden this caller against the possibility. Reviewed-by: Gavin Shan Signed-off-by: Jonathan Cameron Link: https://lore.kernel.org/r/20240529133446.28446-13-Jonathan.Cameron@huawei.com Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin --- arch/arm64/include/asm/acpi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 0d1da93a5bad..702587fda70c 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -102,7 +102,8 @@ static inline int get_cpu_for_acpi_id(u32 uid) int cpu; for (cpu = 0; cpu < nr_cpu_ids; cpu++) - if (uid == get_acpi_id_for_cpu(cpu)) + if (acpi_cpu_get_madt_gicc(cpu) && + uid == get_acpi_id_for_cpu(cpu)) return cpu; return -EINVAL; -- 2.43.0