Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp412516pxu; Thu, 3 Dec 2020 03:33:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPhxftIs54X/h+RiCSZeFZlvVjv4ilJd58lY0rYtp17AQw5dR8BIgFt9QdgJjIZcAGF7LQ X-Received: by 2002:a17:906:1294:: with SMTP id k20mr2075846ejb.404.1606995191895; Thu, 03 Dec 2020 03:33:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606995191; cv=none; d=google.com; s=arc-20160816; b=nAux3xf2820/eYo0iHxuthy6196fUq38QAK6QGw5oJtfdS+hnAv7Ul3j3cz0p2dYgz vATD7hAevFWPrAHiGHtWKXeZ/4aYuz2tLWMZQ88jIqONK/tUwLTcCMeQXN/pDw1Cozt1 qtW/a/CJWhT6SvYDdVzMA+XXURxw0aI72N1Z+JMDRlcbA3GRo98VW9+a48kSRA24hukh +wglkAY53khN0sjC3s5+1p+nXQTz1pDYjNf+VMGIY9bWgR+SnHnqgRJEjak+NmR1T8y/ zguLJNMzIwfWq8N+fQ/fgXtkA4f0RUkE9KsxQ6XzETvwFJUbrBOLcrghuA+HISe0aoH0 p1pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=77634Hpz1Np2ivTRGU8D9nR6eKIuTTV+7WZB7ZFa4D4=; b=d71luEJL+9opt0yC6fWt3k+Nk/dbC/BAYVUz6eXCNFTNyTv8zkFH8p5c8OoVUgokso 6nbZJowEhjKmFqPTRqIjCFjuqU8MPcl2r6BIb2RlJgfYxFhOg9w8dxZNPq/DPAO/4LCA 8i8ms894/3XQdX8iDLny+XgPlHcDbIjJpjvV9FZhRICmNI5pDYSFRbgvvAgHQKha3PSA GenZ01cuVahTRrIqnfowSCltVr7rnJna8HUs4WXJdmq31gdRyqxHUmgyPm4SlmnU7s/W FQGZmxi9Vw0n9N2F0L69ZFErZl8ucutEXzrSaYgDe0R8IKnVgsDBsfSt4Nm0//GBXnak PT7g== 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=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t27si890166eje.510.2020.12.03.03.32.48; Thu, 03 Dec 2020 03:33:11 -0800 (PST) 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=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730260AbgLCLbJ (ORCPT + 99 others); Thu, 3 Dec 2020 06:31:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:58280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728782AbgLCLbI (ORCPT ); Thu, 3 Dec 2020 06:31:08 -0500 Date: Thu, 3 Dec 2020 11:30:21 +0000 From: Catalin Marinas To: Miles Chen Cc: Alexey Dobriyan , Andrew Morton , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com, Andrey Konovalov , Alexander Potapenko , Vincenzo Frascino , Andrey Ryabinin , Dmitry Vyukov , Marco Elver , Will Deacon , "Eric W . Biederman" , Song Bao Hua , stable@vger.kernel.org Subject: Re: [PATCH v2] proc: use untagged_addr() for pagemap_read addresses Message-ID: <20201203113020.GE2224@gaia> References: <20201127050738.14440-1-miles.chen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201127050738.14440-1-miles.chen@mediatek.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 27, 2020 at 01:07:38PM +0800, Miles Chen wrote: > Cc: Will Deacon That should be will@kernel.org. > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > index 217aa2705d5d..92b277388f05 100644 > --- a/fs/proc/task_mmu.c > +++ b/fs/proc/task_mmu.c > @@ -1599,11 +1599,15 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, > > src = *ppos; > svpfn = src / PM_ENTRY_BYTES; > - start_vaddr = svpfn << PAGE_SHIFT; > end_vaddr = mm->task_size; > > /* watch out for wraparound */ > - if (svpfn > mm->task_size >> PAGE_SHIFT) > + start_vaddr = end_vaddr; > + if (svpfn < (ULONG_MAX >> PAGE_SHIFT)) Does this need to be strict less-than? I think a less-than or equal would work better. > + start_vaddr = untagged_addr(svpfn << PAGE_SHIFT); > + > + /* Ensure the address is inside the task */ > + if (start_vaddr > mm->task_size) > start_vaddr = end_vaddr; Otherwise the logic looks fine to me. With the above: Reviewed-by: Catalin Marinas