Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp627119pxx; Mon, 26 Oct 2020 17:21:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaQPvxLgS+8+iNe+39SY0eJq11mpEbdj7Cs2YNh/4kMz/JxrnaoAIIV2Ct1uy1QB3Q9sCW X-Received: by 2002:a17:906:5fd0:: with SMTP id k16mr17972871ejv.140.1603758104589; Mon, 26 Oct 2020 17:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603758104; cv=none; d=google.com; s=arc-20160816; b=IcZhCii5OmiWATxe523FqxDolQo2Kr+VNLE3MuQf06ZGEAls7oUzpIcVUMWBUFSRvo 2maxjm0yS1GbpOee0CxpiJTK2nGn0ebE665WsA7UTuV6PWYzbNqkQ0LRekiKN5jyXJvd +daJg6ct4K/E3jbqIT3igqfRJuH8eJv4OKoFn4Vh0QN2LxGNtta6LyqfRuP0MFLfm/hJ IqFYScdxR5Rfkrv82banxBB6XpKLuCWqvCcvpPCWR6LNE7yJX2LriqtqIQYcstGkMnsp OIqcKQF5RJM+aWwKpfUuGSXje1Y5mwOR+v3ZyLdYryClEKk5pS5QbebjjgGZ5EgYg3XJ TJJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uPhwVVTVLvrPaMTLA4J/JVC12/OXOYWEV/iFy5iO2Kk=; b=l10uTYnkQJTqvy1Vf2qmcJ0Ym7DzP+eEXw8Ud1escknGRMQoUarNmc0AAi8cL6yIHg Rm6wZ9MzfgIuw+Y4fHSP3ida4xqsxWumuluvV74NkbSq4NW7GxNXWAzd4I2BKAgVkP7q WtWGxJBtTLxNecEXb3wyfK2NCh6u5s9uvcRSNyh24bo7xl1gyVWFeJRx8ZGMFOpdwIIe hAIGBoeP6p2MYrwuKJmXzGHT09xqFWQX9vhguIsZPJPGJXN//R07tkdxZuu73o0H4aPB Whxt/F0v4vbOWMhWaqFji7ya3rtL4lNB+oNmPDFxOBe3h25n4axOEmZEsVq0ygmwwxb7 pOvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ot8sWUFZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ec23si8556900ejb.575.2020.10.26.17.21.22; Mon, 26 Oct 2020 17:21:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ot8sWUFZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387622AbgJ0ADB (ORCPT + 99 others); Mon, 26 Oct 2020 20:03:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:35522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2411058AbgJZX4N (ORCPT ); Mon, 26 Oct 2020 19:56:13 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B758B221FA; Mon, 26 Oct 2020 23:56:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756572; bh=mlv3sstlxvv/A+9qqtzkJ4Tyr6KpKttPUzMEqjjuJRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ot8sWUFZhLBh5Rokb55Q1g5NsTB3/XhIOkLT+PCrPlKpy+MwdsMrztg20G9oW9mIV pUDIFpKIUUVY6ySO+hs6q46lYhYZIOGklF48w071rolIDkY72L1z7+ekh3ZSTvjX4l quirCTPbemwGZiLGyQst3jb/bCUxuTdsU7107Ewo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jonathan Cameron , Barry Song , Hanjun Guo , "Rafael J . Wysocki" , Sasha Levin , linux-acpi@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 46/80] ACPI: Add out of bounds and numa_off protections to pxm_to_node() Date: Mon, 26 Oct 2020 19:54:42 -0400 Message-Id: <20201026235516.1025100-46-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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]; } -- 2.25.1