From patchwork Tue Nov 3 20:36:20 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: 316972 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 B9B44C388F9 for ; Tue, 3 Nov 2020 21:22:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68C8C21534 for ; Tue, 3 Nov 2020 21:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604438550; bh=pJWyievTSLGQwL+AD1woiGSadxvuzSbbpbcwj3unWVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aZTqk4T3IKVPzFRFOfiDjRinKTzse2QhtkLmRWHnYIcXI8wiRdpT6mx0GBLSmfDhk iiY8jwxzzOArzWboq1/SIoBnPdSUcikUiDGYnjanEkaZ/5DQHd7ZkPmmY602aqPmTm OV4hEMxX79P/t6/L8mQ5fDvCU+BRqN3E3G/m0Uzg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728511AbgKCVWZ (ORCPT ); Tue, 3 Nov 2020 16:22:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:44008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733070AbgKCVF3 (ORCPT ); Tue, 3 Nov 2020 16:05:29 -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 1510920658; Tue, 3 Nov 2020 21:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437528; bh=pJWyievTSLGQwL+AD1woiGSadxvuzSbbpbcwj3unWVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x+0GhBEfwaDKhm+pU3CMPPCXfY4EXrCRvEMOqx4I0HMqN2rIs17/uSrRDJeqeaVUt NvUI7W1IDZ9Vh4e8djNOxVnQJHdoffAoeoXi54PE9mhvcp7oZTFoowu/dbfE+pFaNJ RyDgT0ddtz1xU+ovQM6SnfCey+sJZk5uzA4DaMR0= 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 4.19 088/191] ACPI: Add out of bounds and numa_off protections to pxm_to_node() Date: Tue, 3 Nov 2020 21:36:20 +0100 Message-Id: <20201103203242.263300277@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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 0da58f0bf7e59..a28ff3cfbc296 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -46,7 +46,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]; }