From patchwork Tue Aug 18 14:24:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 247891 Delivered-To: patch@linaro.org Received: by 2002:a54:3b12:0:0:0:0:0 with SMTP id j18csp3177578ect; Tue, 18 Aug 2020 07:25:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk+UN3AaRWIbmsGLSstyG/oymfO8jacll9qgYN6c+vr8HWnYirL/b5sW2gfjPp5vhGYDHU X-Received: by 2002:aa7:cccb:: with SMTP id y11mr11043295edt.15.1597760748804; Tue, 18 Aug 2020 07:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597760748; cv=none; d=google.com; s=arc-20160816; b=caDu7MAxMhFGrKh0Pit0pNhWw+HydfrUgRlEnYnnaoaJF9GKF1xsNjEOnQr6eTvXzm WXoVPCG4J/g3eCDcwVAmaFg4wacqmuZQQflBe2xOk3Jc94Qd1hUWLzo/8VvCGZgDY+Pq WcrVzkqAL5AAp9zY9QLctxVEE2q8dWUp94vvxoQxWaEY8UimYxFIHIA8n0jbXVSGQI+D QVhNFLHBtL7iUaVHDEnNTKB+rVbZQWfcm9gElylLsBPY0TfMI1JSumWPqHI6aDB7nvqM r1J7gljAQSpH4U4d/qMXJNe7vOG/Qnf994oCd+6aPleGIfy+VB+danrhLTPn/g7wZgbG A7qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nu3pb3gTBHTvnW4SDEYq0nEruLNXGVc3G9T9yz/AQ10=; b=fC72S0wIAPMbu6mG6/aI+JJeFRtr/anOY7KQB/9xR0GcAx/EpN5prcJlM3VNJUpnq3 ZLRjnCsEGHlSLLNFvjtZPGeXVpIYs2XqRO4TANLuNHSZsn93xSAMVFMoIbkMwkMRNGqd 9TqK2UJVDZZl76DyxXF3bezIgPMG/KoDXhGL0L6sOTwXBG2u5CmRUfE80BgjT93RHk+U kfvBGb37Q2/hDv8WPmk5VWP8EHv1BBg6l9CYqTG9blCysMMbv0tY0ZoeyU/l0J/LKJ32 caEr9FSp1a9ERa+eTxEVhyH4fg4vs9QKBIX3NHWIreIsvvW4ooUc29Re5L//vcxvmkdq U3Eg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r8si5318233ejr.677.2020.08.18.07.25.48; Tue, 18 Aug 2020 07:25:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbgHROZp (ORCPT + 7 others); Tue, 18 Aug 2020 10:25:45 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2617 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726747AbgHROZh (ORCPT ); Tue, 18 Aug 2020 10:25:37 -0400 Received: from lhreml710-chm.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id 916AF35EF72127693B1B; Tue, 18 Aug 2020 15:25:35 +0100 (IST) Received: from lhrphicprd00229.huawei.com (10.123.41.22) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Tue, 18 Aug 2020 15:25:35 +0100 From: Jonathan Cameron To: , , , CC: Lorenzo Pieralisi , Bjorn Helgaas , , , Ingo Molnar , , Tony Luck , Fenghua Yu , Thomas Gleixner , , Dan Williams , Song Bao Hua , Jonathan Cameron Subject: [PATCH v3 1/6] ACPI: Add out of bounds and numa_off protections to pxm_to_node Date: Tue, 18 Aug 2020 22:24:25 +0800 Message-ID: <20200818142430.1156547-2-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200818142430.1156547-1-Jonathan.Cameron@huawei.com> References: <20200818142430.1156547-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.123.41.22] X-ClientProxiedBy: lhreml710-chm.china.huawei.com (10.201.108.61) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- drivers/acpi/numa/srat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.19.1 diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index 15bbaab8500b..1fb486f46ee2 100644 --- a/drivers/acpi/numa/srat.c +++ b/drivers/acpi/numa/srat.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]; }