From patchwork Tue Nov 3 20:35:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 316872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98637C388F9 for ; Tue, 3 Nov 2020 21:42:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5357F22384 for ; Tue, 3 Nov 2020 21:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604439775; bh=2krI4vKDGlGHCjoREsfWY8/0uJTjTAT40akVRkQ4d1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=MiTEMsJXXf33ckMMUbfUHq1F4tykHypgDSEqKzHJSUtvfgHPUO4ne2jg4ny37XXu/ JmI5acCLpQy44/Sh6a5k3zPw0vZIvFBpYxzm8YW/xxmboI+shToxwQ6YFT7BwregAC lpl1HAWYu/9AC2p6H3TVb8oREXELfWoC/h8xkq/4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731922AbgKCUzQ (ORCPT ); Tue, 3 Nov 2020 15:55:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:55492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731206AbgKCUzP (ORCPT ); Tue, 3 Nov 2020 15:55:15 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C3F4322226; Tue, 3 Nov 2020 20:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436915; bh=2krI4vKDGlGHCjoREsfWY8/0uJTjTAT40akVRkQ4d1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tpE80jnjsE6x5dJ6bF7M6N7Ke4xICLvxXUg4+hIvmQmlZE2+/Bvqd9SkWxs8SvoZ7 fVMod09f3qvCp1o9cEgUo+9dH1srshHQtb6i3pzCS2gF7uJX8s061DoyMmLMnDSRUP xy5eoiThlL4HhiAtM7Xulxr/Pf0Twc6VNIjzIr/c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Barry Song , Hanjun Guo , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.4 065/214] ACPI: Add out of bounds and numa_off protections to pxm_to_node() Date: Tue, 3 Nov 2020 21:35:13 +0100 Message-Id: <20201103203256.474462114@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jonathan Cameron [ Upstream commit 8a3decac087aa897df5af04358c2089e52e70ac4 ] The function should check the validity of the pxm value before using it to index the pxm_to_node_map[] array. Whilst hardening this code may be good in general, the main intent here is to enable following patches that use this function to replace acpi_map_pxm_to_node() for non SRAT usecases which should return NO_NUMA_NODE for PXM entries not matching with those in SRAT. Signed-off-by: Jonathan Cameron Reviewed-by: Barry Song Reviewed-by: Hanjun Guo Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/numa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index eadbf90e65d14..85e01752fbe47 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -31,7 +31,7 @@ int acpi_numa __initdata; int pxm_to_node(int pxm) { - if (pxm < 0) + if (pxm < 0 || pxm >= MAX_PXM_DOMAINS || numa_off) return NUMA_NO_NODE; return pxm_to_node_map[pxm]; }