Re: [PATCH] fs/hugetlbfs/inode.c: Ensure generic_hugetlb_get_unmapped_area() returns higher address than mmap_min_addr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 7/5/24 17:53, Kirill A . Shutemov wrote:
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.
Thank you for your comment. I will add this change and send V2.

-Donet

Hugetlb code duplication is annoying.





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux