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 CFC167581D; Tue, 10 Sep 2024 10:36:25 +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=1725964585; cv=none; b=VCsix0k5DP1vcE5AJZxSdrA7aO4N2FnzbxzCN/t80ouIR4lMwsM48U1btvWCtKC4VPxBf/CEhbN9wbs5G3OzZ0mARh+97tWBHblvqSUFPlqkOBtTD5g8yxNae6JiDoKRkzfWa5vjC5q5zMH/dMjDX9lWkTgTzjStVKqO6vmveBU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725964585; c=relaxed/simple; bh=7oy/l+fJChehHRS2pj/fxA5fE54f7pbu4pvO8GW6Wvo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KvJOz9gbpzjtnzXtctte68nI+hCDLMhk7+J7MJxZjOX0s+2ifIZewo8YDaD9hWKBXoaPlpXyvF74CvkXuGOk1jAfSY64gDzcy5W7sYTRfgtasZWkOkeSb1Bpf3k34EnSzW1mSrFRvCgpvJTUCHexr0/otKr8cOxrVlm1Q8zF164= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Z6XvSuLB; 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="Z6XvSuLB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34BE8C4CEC3; Tue, 10 Sep 2024 10:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725964585; bh=7oy/l+fJChehHRS2pj/fxA5fE54f7pbu4pvO8GW6Wvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z6XvSuLBXXQLccZwwv84e0dSLxM0e6NCS6bubXsuVNqgIvY5WEUlj15B+yXDpqIO8 2W3UD8XyrLCaii5m4aD5vO+peZem3m0jPOqp4e2HTidzdLOuPqBq/kvRAt2k9NC6V+ sYBF9MWlhcJeU6qMmg+MYRe8L3QP1kNMBpUtuiDA= 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 6.6 232/269] arm64: acpi: Harden get_cpu_for_acpi_id() against missing CPU entry Date: Tue, 10 Sep 2024 11:33:39 +0200 Message-ID: <20240910092616.178625079@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240910092608.225137854@linuxfoundation.org> References: <20240910092608.225137854@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 6.6-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 bc9a6656fc0c..a407f9cd549e 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -124,7 +124,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