public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel McNeil <daniel@osdl.org>
To: Ingo Molnar <mingo@redhat.com>
Cc: Mark Haverkamp <markh@osdl.org>,
	davidm@hpl.hp.com, Linus Torvalds <torvalds@osdl.org>,
	Jakub Jelinek <jakub@redhat.com>,
	suresh.b.siddha@intel.com, jun.nakajima@intel.com,
	Andrew Morton <akpm@osdl.org>,
	linux-ia64@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] mmap PROT_NONE fix (was Re: serious performance regression
Date: Wed, 14 Jul 2004 18:36:41 +0000	[thread overview]
Message-ID: <1089830200.2285.25.camel@ibm-c.pdx.osdl.net> (raw)
In-Reply-To: <1089737382.2600.60.camel@ibm-c.pdx.osdl.net>

This patch fixes mmap PROT_NONE from elf binaries that do not
have the PT_GNU_STACK so that the do not have execute permission.

Before this fix, calling access() with a PROT_NONE page
was returning ENOENT instead of EFAULT.

BEFORE: 
$ x.gcc322
p2=0x40013000
pid\x1982
 
access 0 ptr (nil) return code -1 errno 14
access result:: Bad address
access 1 ptr 0xffffffff return code -1 errno 14
access result:: Bad address
access 2 ptr 0x40013000 return code -1 errno 2
access result:: No such file or directory

AFTER:

$ ./x.gcc322
p2=0x40017000
pid$92
                                                                                
access 0 ptr (nil) return code -1 errno 14
access result:: Bad address
access 1 ptr 0xffffffff return code -1 errno 14
access result:: Bad address
access 2 ptr 0x40017000 return code -1 errno 14
access result:: Bad address


Program available at
http://developer.osdl.org/daniel/mmap.PROT_NONE.bug/

Here is the patch.

Signed-off-by: Daniel McNeil <daniel@osdl.org>


=== mm/mmap.c 1.133 vs edited ==--- 1.133/mm/mmap.c	2004-06-29 07:43:12 -07:00
+++ edited/mm/mmap.c	2004-07-14 09:56:37 -07:00
@@ -792,6 +792,12 @@
 	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
 			mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
 
+	/*
+	 * mm->def_flags might have VM_EXEC set, which PROT_NONE does NOT want.
+	 */
+	if (prot = PROT_NONE)
+		vm_flags &= ~VM_EXEC;
+
 	if (flags & MAP_LOCKED) {
 		if (!capable(CAP_IPC_LOCK))
 			return -EPERM;



  reply	other threads:[~2004-07-14 18:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-10  5:28 serious performance regression due to NX patch David Mosberger
2004-07-11  8:38 ` Ingo Molnar
2004-07-11  9:39   ` Ingo Molnar
2004-07-11  9:52     ` Ingo Molnar
2004-07-11 10:02       ` Andrew Morton
2004-07-11 12:19         ` Matthew Wilcox
2004-07-11 10:22       ` Christoph Hellwig
2004-07-11 12:38       ` Jakub Jelinek
2004-07-12 18:08         ` Ingo Molnar
2004-07-12 18:24           ` Christoph Hellwig
2004-07-12 18:29             ` Ingo Molnar
2004-07-12 19:10               ` David Mosberger
2004-07-12 19:54                 ` Ingo Molnar
2004-07-12 20:08                   ` David Mosberger
2004-07-12 20:17           ` Linus Torvalds
2004-07-12 20:21             ` David Mosberger
2004-07-12 20:24             ` David Mosberger
2004-07-13  4:23               ` Ingo Molnar
2004-07-13  5:23                 ` David Mosberger
2004-07-13 16:05                 ` Mark Haverkamp
2004-07-13 16:49                   ` Daniel McNeil
2004-07-14 18:36                     ` Daniel McNeil [this message]
2004-07-17  0:06                   ` David Mosberger
2004-07-17  1:39                     ` Linus Torvalds
2004-07-17  4:37                       ` David Mosberger
2004-07-13  3:58             ` Ingo Molnar
2004-07-17  0:35     ` David Mosberger

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=1089830200.2285.25.camel@ibm-c.pdx.osdl.net \
    --to=daniel@osdl.org \
    --cc=akpm@osdl.org \
    --cc=davidm@hpl.hp.com \
    --cc=jakub@redhat.com \
    --cc=jun.nakajima@intel.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markh@osdl.org \
    --cc=mingo@redhat.com \
    --cc=suresh.b.siddha@intel.com \
    --cc=torvalds@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox