Skip to contentSkip to conversation

mmap.c corner case fix

PATCH New DervishD 1 participant 1 message Jan 14, 2003

Subsystems (2)
lore
Share & tools
lore

DervishD

author
#0 lore raw

PATCH 1/1 mmap.c corner case fix

Hi Marcelo :)

This patch fixes a corner case on the mmap() syscall.

The patch is from David S. Miller, not me. My patch was
incomplete and did nothing on 'big TASK_SIZE' architectures.

The patch is against both 2.4.20 and 2.4.21-pre, is just the same.
Please apply. I sent you the incomplete patch at pre-1 and this bug is getting older by the minute ;))

Thanks :)

Raúl

mm/mmap.c renamed from mm/mmap.c.orig +4 -2
@@ -403,10 +403,12 @@
 	if (file && (!file->f_op || !file->f_op->mmap))
 		return -ENODEV;
 
-	if ((len = PAGE_ALIGN(len)) == 0)
+	if (!len)
 		return addr;
 
-	if (len > TASK_SIZE)
+	len = PAGE_ALIGN(len);
+
+	if (len > TASK_SIZE || len == 0)
 		return -EINVAL;
 
 	/* offset overflow? */