lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <n5jwq5uq3hrgu3ksyg34tjtl3hw5izpc5s5lac4pkjfjt2tf22@co5rgjcznsma>
Date: Fri, 5 Jul 2024 15:23:11 +0300
From: "Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>
To: Donet Tom <donettom@...ux.ibm.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, 
	Muchun Song <muchun.song@...ux.dev>, linux-mm@...ck.org, linux-kernel@...r.kernel.org, 
	Ritesh Harjani <ritesh.list@...il.com>, Mike Rapoport <rppt@...nel.org>, 
	David Hildenbrand <david@...hat.com>, Matthew Wilcox <willy@...radead.org>, 
	Tony Battersby <tonyb@...ernetics.com>, "Aneesh Kumar K . V" <aneesh.kumar@...nel.org>, 
	Nicholas Piggin <npiggin@...il.com>, Alexei Starovoitov <ast@...nel.org>, 
	Andy Lutomirski <luto@...nel.org>, jj@...ck.fi.intel.com
Subject: Re: [PATCH] fs/hugetlbfs/inode.c: Ensure
 generic_hugetlb_get_unmapped_area() returns higher address than
 mmap_min_addr

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ