Skip to contentSkip to conversation

mmap.c - do_mmap_pgoff() small correction

PATCH Superseded DervishD 1 participant 2 messages Dec 11, 2002 – Feb 11, 2003

Subsystems (2)
lore
Share & tools
lore

DervishD

author
#0 lore raw

PATCH 1/1 mmap.c - do_mmap_pgoff() small correction

Hi Linus :)

This is a correction for a patch I sent you that you included in
the 2.5.x tree. The patch I sent you fixed a corner case for the mmap() syscall, where the requested size was too big (namely, bigger than SIZE_MAX-PAGE_SIZE). Unfortunately, the patch did a wrong assumption that is not true in some archs where TASK_SIZE is the full address space available, as sparc64. So, the patch didn't fix anything on those archs :((

David S. Miller <[email protected]> pointed this and made this new
patch that fixes the spot. Now it should work in all archs.

If you have any doubt, just tell.

Raúl

mm/mmap.c renamed from mm/mmap.c.orig +4 -4
@@ -421,14 +421,14 @@
 	if (file && (!file->f_op || !file->f_op->mmap))
 		return -ENODEV;
 
-	if (!len)
+	if (len == 0)
 		return addr;
 
-	if (len > TASK_SIZE)
-		return -EINVAL;
-
 	len = PAGE_ALIGN(len);
 
+	if (len > TASK_SIZE || len == 0)
+		return -EINVAL;
+
 	/* offset overflow? */
 	if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
 		return -EINVAL;
author
#1 lore raw

PATCH RESEND 1/1 mmap.c - do_mmap_pgoff() small correction

Hi Linus :)

This is a correction for a patch I sent you that you included in
the 2.5.x tree. The patch I sent you fixed a corner case for the mmap() syscall, where the requested size was too big (namely, bigger than SIZE_MAX-PAGE_SIZE). Unfortunately, the patch did a wrong assumption that is not true in some archs where TASK_SIZE is the full address space available, as sparc64. So, the patch didn't fix anything on those archs :((

David S. Miller <[email protected]> pointed this and made this new
patch that fixes the spot. Now it should work in all archs.

If you have any doubt, just tell. The patch is against 2.5.60,
please apply or the corner case won't be fixed on sparc64. Thanks a lot :)

Raúl