Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3738443pxj; Mon, 21 Jun 2021 05:36:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiLbVRczGGTu06YlNqsvWBUYbwFo9fKUY8p8c6haRPytHq36m2Vo9PC1RAyLn5Sj7YMEH6 X-Received: by 2002:a6b:7110:: with SMTP id q16mr19553452iog.53.1624279008068; Mon, 21 Jun 2021 05:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624279008; cv=none; d=google.com; s=arc-20160816; b=zD0/dqwh8stVrPjfeeyPGL8xwz384IpkXo4UFcrLkyjF7GLapDQcvM1mDnTvumDZDH XkyFM9CE9z4qM+ORaWA8p5PJaQgdkw9WSr7y+GshfGvi2O3kxPPbUYm4RoNnfyP0r0Yj QN0U+MapdwqFDmH18+jljW205mvrXFRxL1Q3iC9JGdDCWxzBjTUELhPMyu2txGVApE3q LrBVGAtBDmOtbIQE2EAvzHBsWHqKwSRoLkk4jcOn2Ssh3WMltWX5ACAOiVFam3QcHGvN E+/LfYzyM7uss0DaqNetgA9OZeLYCEeQuOYA1lJM/iT6FuEDYjxZY6JpcxE/yiPUBq5T dZCg== 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; bh=xsKhH8HXJjiSlcsezNgO1Avu0DF5qMWCBRnpIGnebnk=; b=xEnw5H+e8kJXJxe8ef1A0LuRyCw+5ccvNdhk82lZ/u+sNo9gscHheQ1QAUpmjRSK4+ 4Qxjn7eE4HIYBqOYz1g2U6VY8Hko/222rEDAtk++uFAWEB8QqXWsSGnI3GVtdDQHUki8 oI/LmQEteJdfg7/OD2DUyXkPaV/FDc4KrLWEu03SlGzuXP+IqxvD4DeoqYT9jYFdNHNe C1W9hVaB/LbeKywzll7alTD0CDRbBdvgXbZdq0BMs5x8qYNN+sn9mWWUrWkwQ1N5u5kT M7Hen5Kd/QUeJG4TmeXa8svqmlRzKWf81Z0NCdesSe7I4rG3u74fMfqUfAMkyexvt+BK fo8w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u5si13319966ill.146.2021.06.21.05.36.35; Mon, 21 Jun 2021 05:36:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbhFUMiF (ORCPT + 99 others); Mon, 21 Jun 2021 08:38:05 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:48286 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbhFUMiB (ORCPT ); Mon, 21 Jun 2021 08:38:01 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R541e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=yaohuiwang@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0UdA8ykB_1624278944; Received: from localhost(mailfrom:yaohuiwang@linux.alibaba.com fp:SMTPD_---0UdA8ykB_1624278944) by smtp.aliyun-inc.com(127.0.0.1); Mon, 21 Jun 2021 20:35:44 +0800 From: Yaohui Wang To: dave.hansen@linux.intel.com, tglx@linutronix.de Cc: luto@kernel.org, peterz@infradead.org, mingo@redhat.com, bp@alien8.de, x86@kernel.org, linux-kernel@vger.kernel.org, luoben@linux.alibaba.com, yaohuiwang@linux.alibaba.com Subject: [PATCH v3 2/2] kernel/resource: fix boundary judgment issues in find_next_iomem_res() and __walk_iomem_res_desc() Date: Mon, 21 Jun 2021 20:34:19 +0800 Message-Id: <20210621123419.2976-3-yaohuiwang@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210621123419.2976-1-yaohuiwang@linux.alibaba.com> References: <20210621123419.2976-1-yaohuiwang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Memory resources are described with the start address and the inclusive end address, which means for a resource with 1 byte length the start address is the same as the end address. find_next_iomem_res() and __walk_iomem_res_desc() ignore resources with 1 byte length, which prevents that ioremap_xxx(phys_addr, 1) is checked whether it touches non-ioremappable resources. Fixes: 010a93bf97c7 (resource: Fix find_next_iomem_res() iteration issue) Fixes: b69c2e20f6e4 (resource: Clean it up a bit) Signed-off-by: Yahui Wang Signed-off-by: Ben Luo --- kernel/resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index ca9f5198a01f..31e371babfad 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -344,7 +344,7 @@ static int find_next_iomem_res(resource_size_t start, resource_size_t end, if (!res) return -EINVAL; - if (start >= end) + if (start > end) return -EINVAL; read_lock(&resource_lock); @@ -392,7 +392,7 @@ static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end, struct resource res; int ret = -EINVAL; - while (start < end && + while (start <= end && !find_next_iomem_res(start, end, flags, desc, &res)) { ret = (*func)(&res, arg); if (ret) -- 2.25.1