From patchwork Fri Oct 26 13:57:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 149593 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp799057ljp; Fri, 26 Oct 2018 06:56:29 -0700 (PDT) X-Google-Smtp-Source: AJdET5cGVcVmo2SZBAh6ctz/wOomWSjXZtB+GYd6AlDoCdfyWuOG44J1lhvsajFfWgT+h7COoVKM X-Received: by 2002:a17:902:9693:: with SMTP id n19-v6mr3651274plp.20.1540562189458; Fri, 26 Oct 2018 06:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540562189; cv=none; d=google.com; s=arc-20160816; b=SJ0Q0rOKPIAxIUGNajNRkSGalb6yWVIzvvw7lAlUFtfhrDa6yY7vGoRHzXtmyK67mt u4nPPpaT5BWNdjX7JrtS1afXduwYI2dmgBcQVnuia30cGEg85qBulVogel0RzrR6d7IT XgHxZUh8tGaw0s+1IJ60dQbuqFQ7eR/vTJUB0AikrdpKoZmnk0AN6xlpT1PAq7EDjLLK Y2w3P/iWiQxCET2BZ75v4QU5qWXwOsAWJ8OF6QjnnwUbDCICybliVWcLxkVVYKkGBWEq 6lr/0VWnHPQTMdsuHXbks8bFfF6DBPnz8T18EQEPp0qaTaG+/E2co0zTfCmXbthAxnxf yC+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=kLhPPZAvYXN84FKVMnm8rHuNDgj4OBk4I8J0rPzQ8rA=; b=ti1inRfXpAhwmAsneGQpXfTP7HAYI09Gm+AU/HyaDXgr4PHDGW1H+wtGMSC+iFy9ce P5z+Z2r323kYLxTrhF9EU88AENeEmZocdVokNx/te6AUcEMgG2i09tTcJf4B4JD9xo7m KKmf6VSuTsPciHOcDaTXw2MQXPlLpqY6b7S7jEOaQxpX5jDVO3ulY+EUJL24uE3cA4Lb rIfQfjXWlnGfC3Rj346jmqlNupA09NtF6D9fU2Ac2GmKsdMxc0nadsF0PS+2gBA+3ifE emovMhGFMObFk74gxea14YTcbxvAVpBIK39+AYn2jWDjNdms+GBUEPGuoePBGx25CfOo q3dA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 62-v6si3609859plb.277.2018.10.26.06.56.29; Fri, 26 Oct 2018 06:56:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726408AbeJZWdh (ORCPT + 32 others); Fri, 26 Oct 2018 18:33:37 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:59533 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726014AbeJZWdh (ORCPT ); Fri, 26 Oct 2018 18:33:37 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 378C7C40EAC34; Fri, 26 Oct 2018 21:56:21 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.408.0; Fri, 26 Oct 2018 21:56:14 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH] arm64/numa: Add more vetting in numa_set_distance() Date: Fri, 26 Oct 2018 21:57:47 +0800 Message-ID: <1540562267-101152-1-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently it is acceptable to set the distance between 2 separate nodes to LOCAL_DISTANCE. Reject this as it is invalid. This change avoids a crash reported in [1]. [1] https://www.spinics.net/lists/arm-kernel/msg683304.html Signed-off-by: John Garry -- 1.9.1 diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c index 146c04c..6092e3d 100644 --- a/arch/arm64/mm/numa.c +++ b/arch/arm64/mm/numa.c @@ -335,7 +335,8 @@ void __init numa_set_distance(int from, int to, int distance) } if ((u8)distance != distance || - (from == to && distance != LOCAL_DISTANCE)) { + (from == to && distance != LOCAL_DISTANCE) || + (from != to && distance == LOCAL_DISTANCE)) { pr_warn_once("Warning: invalid distance parameter, from=%d to=%d distance=%d\n", from, to, distance); return;