From: DervishD <raul@viadomus.com>
To: vda@port.imtp.ilyichevsk.odessa.ua
Cc: marcelo@conectiva.com.br, Linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: mmap() doesn't like certain value...
Date: Sat, 11 May 2002 01:50:21 +0200 [thread overview]
Message-ID: <3CDC5CBD.mail72C11PGID@viadomus.com> (raw)
In-Reply-To: <3CD983C5.mail1K71EX1NG@viadomus.com> <200205100810.g4A8AaX28554@Port.imtp.ilyichevsk.odessa.ua> <3CDB8740.mailBO1BW5NO@viadomus.com> <200205101438.g4AEc9X29850@Port.imtp.ilyichevsk.odessa.ua>
Hi Denis and Marcelo :)
>> And is corrected just by inverting the two quoted code snips :)
>You are right
I've added a couple of comments and one more test. I don't think
that mmap() should return 'addr' when len=0. Moreover, mmap() cannot
return '0' under *any* circumstance (so says the man page).
I've tested the patch with a little program to test every
possible 'len' value and checking for mmap() returning the correct
value.
This is the patch:
--- begin ---
--- mm/mmap.c.orig 2002-05-10 10:40:51.000000000 +0200
+++ mm/mmap.c 2002-05-10 10:47:54.000000000 +0200
@@ -389,6 +389,11 @@
return 0;
}
+
+/*
+ NOTE: in this function we rely on TASK_SIZE being lower than
+SIZE_MAX-PAGE_SIZE at least. I'm pretty sure that it is.
+*/
unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, unsigned long len,
unsigned long prot, unsigned long flags, unsigned long pgoff)
{
@@ -402,12 +407,11 @@
if (file && (!file->f_op || !file->f_op->mmap))
return -ENODEV;
- if ((len = PAGE_ALIGN(len)) == 0)
- return addr;
-
- if (len > TASK_SIZE)
+ if (!len || len > TASK_SIZE)
return -EINVAL;
+ len = PAGE_ALIGN(len); /* This CANNOT be zero */
+
/* offset overflow? */
if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
return -EINVAL;
--- end ---
>> I'll give a try to the inversion, that should work. I have
>> written a small stress program for mmap, so in a few hours the patch
>> will be ready. Must I post it here or send it directly to Marcello?
>Post here and to Marcelo. BTW, is 2.5 affected?
I don't really know, but I'm pretty sure... Anyway I think that
the same patch is valid for both kernels with little or no
modification.
BTW, the patch is not only mine, David Gómez Espinosa
(davidge@viadomus.com) has helped me with this issue too.
Raúl
prev parent reply other threads:[~2002-05-10 23:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-08 20:00 mmap() doesn't like certain value DervishD
2002-05-10 13:13 ` Denis Vlasenko
2002-05-10 8:39 ` DervishD
2002-05-10 19:41 ` Denis Vlasenko
2002-05-10 23:50 ` DervishD [this message]
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=3CDC5CBD.mail72C11PGID@viadomus.com \
--to=raul@viadomus.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
--cc=vda@port.imtp.ilyichevsk.odessa.ua \
/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