From: root <davidm@hpl.hp.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] problem with mmap?
Date: Tue, 12 Jun 2001 06:32:00 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590693005714@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590693005712@msgid-missing>
>>>>> On 11 Jun 2001 16:56:55 -0600, Bdale Garbee <bdale@gag.com> said:
Bdale> In chasing down a problem in the Debian installation toolset
Bdale> where sed was generating no output when processing
Bdale> /proc/mounts, we discovered what looks like a bug.
Bdale> The kernel is allowing an mmap of /proc/mounts to succeed,
Bdale> which gives sed a 0-byte mmap'ed file. On other
Bdale> architectures, the mmap fails so sed resorts to normal
Bdale> reading which works fine.
Good catch! This was caused by an accidental reversal of two
special-case/error tests. This had the effect that a zero-length
mmap() would always succeed, even though it should fail with EBADF on
a non-anonymous mmap() of a file that doesn't support the mmap()
operation (as is the case for /proc/mounts).
The attached patch fixes the problem.
Thanks,
--davidm
--- arch/ia64/kernel/sys_ia64.c~ Sun Apr 29 17:12:35 2001
+++ arch/ia64/kernel/sys_ia64.c Mon Jun 11 22:27:42 2001
@@ -178,11 +178,22 @@
unsigned long roff;
struct file *file = 0;
+ flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+ if (!(flags & MAP_ANONYMOUS)) {
+ file = fget(fd);
+ if (!file)
+ return -EBADF;
+
+ if (!file->f_op || !file->f_op->mmap)
+ return -ENODEV;
+ }
+
/*
- * A zero mmap always succeeds in Linux, independent of
- * whether or not the remaining arguments are valid.
+ * A zero mmap always succeeds in Linux, independent of whether or not the
+ * remaining arguments are valid.
*/
- if (PAGE_ALIGN(len) = 0)
+ len = PAGE_ALIGN(len);
+ if (len = 0)
return addr;
/* don't permit mappings into unmapped space or the virtual page table of a region: */
@@ -193,13 +204,6 @@
/* don't permit mappings that would cross a region boundary: */
if (rgn_index(addr) != rgn_index(addr + len))
return -EINVAL;
-
- flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
- if (!(flags & MAP_ANONYMOUS)) {
- file = fget(fd);
- if (!file)
- return -EBADF;
- }
down_write(¤t->mm->mmap_sem);
addr = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
prev parent reply other threads:[~2001-06-12 6:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-11 22:56 [Linux-ia64] problem with mmap? Bdale Garbee
2001-06-12 6:32 ` root [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=marc-linux-ia64-105590693005714@msgid-missing \
--to=davidm@hpl.hp.com \
--cc=linux-ia64@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.