linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
To: Donet Tom <donettom@linux.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Muchun Song <muchun.song@linux.dev>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 Ritesh Harjani <ritesh.list@gmail.com>,
	Mike Rapoport <rppt@kernel.org>,
	 David Hildenbrand <david@redhat.com>,
	Matthew Wilcox <willy@infradead.org>,
	 Tony Battersby <tonyb@cybernetics.com>,
	"Aneesh Kumar K . V" <aneesh.kumar@kernel.org>,
	 Nicholas Piggin <npiggin@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	 Andy Lutomirski <luto@kernel.org>,
	jj@black.fi.intel.com
Subject: Re: [PATCH] fs/hugetlbfs/inode.c: Ensure generic_hugetlb_get_unmapped_area() returns higher address than mmap_min_addr
Date: Fri, 5 Jul 2024 15:23:11 +0300	[thread overview]
Message-ID: <n5jwq5uq3hrgu3ksyg34tjtl3hw5izpc5s5lac4pkjfjt2tf22@co5rgjcznsma> (raw)
In-Reply-To: <20240705071150.84972-1-donettom@linux.ibm.com>

On Fri, Jul 05, 2024 at 02:11:50AM -0500, Donet Tom wrote:
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 412f295acebe..428fd2f0e4c4 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -228,7 +228,7 @@ generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
>  
>  	if (len & ~huge_page_mask(h))
>  		return -EINVAL;
> -	if (len > TASK_SIZE)
> +	if (len > mmap_end - mmap_min_addr)
>  		return -ENOMEM;
>  
>  	if (flags & MAP_FIXED) {
> @@ -240,7 +240,7 @@ generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
>  	if (addr) {
>  		addr = ALIGN(addr, huge_page_size(h));
>  		vma = find_vma(mm, addr);
> -		if (mmap_end - len >= addr &&
> +		if (mmap_end - len >= addr && addr >= mmap_min_addr &&
>  		    (!vma || addr + len <= vm_start_gap(vma)))
>  			return addr;
>  	}

There's more difference with generic_get_unmapped_area() than what you are
fixing. I think we also need vm_end_gap() here.

Hugetlb code duplication is annoying.

-- 
  Kiryl Shutsemau / Kirill A. Shutemov


  reply	other threads:[~2024-07-05 12:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-05  7:11 Donet Tom
2024-07-05 12:23 ` Kirill A . Shutemov [this message]
2024-07-05 16:48   ` Donet Tom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=n5jwq5uq3hrgu3ksyg34tjtl3hw5izpc5s5lac4pkjfjt2tf22@co5rgjcznsma \
    --to=kirill.shutemov@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@kernel.org \
    --cc=ast@kernel.org \
    --cc=david@redhat.com \
    --cc=donettom@linux.ibm.com \
    --cc=jj@black.fi.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=npiggin@gmail.com \
    --cc=ritesh.list@gmail.com \
    --cc=rppt@kernel.org \
    --cc=tonyb@cybernetics.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox