From patchwork Fri Jul 17 17:59:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 235739 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1925814ilg; Fri, 17 Jul 2020 11:01:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUhNF4G+obNJx5HgcRZVVw4VCpt3156cvRfowN4Lfq5XQycflazFWHs9oW7Cr6zxBWIEDH X-Received: by 2002:a05:6402:1c96:: with SMTP id cy22mr10189415edb.79.1595008877656; Fri, 17 Jul 2020 11:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595008877; cv=none; d=google.com; s=arc-20160816; b=Si5eyeLGQ2zWNXZ5OhotaKzcIEB1qRT4YOf2OSlpPtFbpGsyBcvhYOQiBu3ETPo0Wi YbCADllpkLl+AHG7t9iApDlARSQGr7br/sfDUSpg/ukhmeuaR1Ksjfi7+hHar5SJC/b9 nW2aH3Cb5UGWOkw4p9rHgNGGU87331DcjILbRgfpH9v1ZcP+OoWGMCoZ3g42k7MxWD8G oXId6f6KQbVSI2eSNBMdSwD9mFg6n7Wx2FZLhtBSU3LLuUxkefJGxBO3YBS5nhJXhrgq wLKwp+7Lbsh36cihFCcU/nnP4UOMyc3MUcUatvpYF9g7FHoOkdsH09UkI3Bv4brKnzhp m42g== 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=DdUjPFqzEWRlYT3/OW1on38PUy+Gl1dLp04h9e0yZm8=; b=yjyld1gBvjF705BDtLt7lgPAsq01eB/GwQpbkV1Wzu7EhWEpNc+kahtqgL0xvozWPs APvczBIquEP0vkml0jIs31zMmr/dM+/6Ypjxq/2u3pYvtyqFcCwFfcJGOJ7z2UFtxXu2 l0M2axtgTDUuT2lyLUwdGoqh7CkW9vi0HhsqRB9ql3RYjUmA2S0gw/zYMOh0AKip86JG x71tmD3bJ1dx6I2A95c8TN8Hz/ryX6uTlTtAagv+YpGCVuVYer8LBfdQH/KCYgOOanYN QmovWCIsEU469CupmGNjNcCnhK6DuIkxrujYB3D2gCIOKf1uhqDAWdhDkZsGJkiCw1cR /i0Q== 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 c89si5938817edf.35.2020.07.17.11.01.17; Fri, 17 Jul 2020 11:01:17 -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 S1727002AbgGQSBQ (ORCPT + 7 others); Fri, 17 Jul 2020 14:01:16 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2498 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726232AbgGQSBQ (ORCPT ); Fri, 17 Jul 2020 14:01:16 -0400 Received: from lhreml710-chm.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id 2142BCC913125B7CA8F5; Fri, 17 Jul 2020 19:01:15 +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_CBC_SHA256) id 15.1.1913.5; Fri, 17 Jul 2020 19:01:14 +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 v2 1/6] ACPI: Add out of bounds and numa_off protections to pxm_to_node Date: Sat, 18 Jul 2020 01:59:54 +0800 Message-ID: <20200717175959.899775-2-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200717175959.899775-1-Jonathan.Cameron@huawei.com> References: <20200717175959.899775-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.123.41.22] X-ClientProxiedBy: lhreml706-chm.china.huawei.com (10.201.108.55) 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 --- drivers/acpi/numa/srat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.19.1 Reviewed-by: Barry Song diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index 5be5a977da1b..8ef44ee0d76b 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]; }