linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stas Sergeev <stsp@aknet.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Hugh Dickins <hugh@veritas.com>,
	Ulrich Drepper <drepper@redhat.com>,
	Valdis.Kletnieks@vt.edu, Arjan van de Ven <arjan@infradead.org>,
	Linux kernel <linux-kernel@vger.kernel.org>
Subject: [patch] remove MNT_NOEXEC check for PROT_EXEC MAP_PRIVATE mmaps
Date: Wed, 27 Sep 2006 23:16:57 +0400	[thread overview]
Message-ID: <451ACE29.4080005@aknet.ru> (raw)
In-Reply-To: <4516B721.5070801@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 982 bytes --]

Hi Andrew.

It looks like in a course of a discussion people
agreed that at least for MAP_PRIVATE the MNT_NOEXEC
check makes no sense (no one spoke up otherwise, at least).

The attached patch removes the check for MAP_PRIVATE but
leaves for MAP_SHARED for now, as this was not agreed on.

Reasons:
- MAP_PRIVATE should not behave like that, "ro" and PROT_WRITE
is a witness ("ro" doesn't deny PROT_WRITE for MAP_PRIVATE).
- This is not a security check - file-backed MAP_PRIVATE mmaps
can just be replaced with MAP_PRIVATE | MAP_ANONYMOUS
mmap and read().
- The programs (like AFAIK wine) use MAP_PRIVATE mmaps to
access the windows dlls, which are usually on a "noexec"
fat or ntfs partitions. Wine might be smart enough not to
break but fallback to read(), but this is slower and more
memory-consuming. Some other program may not be that smart
and break. So there is clearly a need for MAP_PRIVATE with
PROT_EXEC on the noexec partitions.

Sign-off: Stas Sergeev <stsp@aknet.ru>

[-- Attachment #2: mapx1.diff --]
[-- Type: text/plain, Size: 1053 bytes --]

--- a/mm/mmap.c	2006-01-25 15:02:24.000000000 +0300
+++ b/mm/mmap.c	2006-09-21 13:19:15.000000000 +0400
@@ -900,7 +900,7 @@
 		if (!file->f_op || !file->f_op->mmap)
 			return -ENODEV;
 
-		if ((prot & PROT_EXEC) &&
+		if ((flags & MAP_SHARED) && (prot & PROT_EXEC) &&
 		    (file->f_vfsmnt->mnt_flags & MNT_NOEXEC))
 			return -EPERM;
 	}
@@ -911,7 +911,8 @@
 	 *  mounted, in which case we dont add PROT_EXEC.)
 	 */
 	if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
-		if (!(file && (file->f_vfsmnt->mnt_flags & MNT_NOEXEC)))
+		if (!(file && (flags & MAP_SHARED) &&
+				(file->f_vfsmnt->mnt_flags & MNT_NOEXEC)))
 			prot |= PROT_EXEC;
 
 	if (!len)
--- a/mm/nommu.c	2006-04-12 09:37:34.000000000 +0400
+++ b/mm/nommu.c	2006-09-21 13:21:32.000000000 +0400
@@ -495,7 +495,7 @@
 
 		/* handle executable mappings and implied executable
 		 * mappings */
-		if (file->f_vfsmnt->mnt_flags & MNT_NOEXEC) {
+		if ((flags & MAP_SHARED) && file->f_vfsmnt->mnt_flags & MNT_NOEXEC) {
 			if (prot & PROT_EXEC)
 				return -EPERM;
 		}

  parent reply	other threads:[~2006-09-27 19:15 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-23 10:30 [patch] remove MNT_NOEXEC check for PROT_EXEC mmaps Stas Sergeev
2006-09-23 15:16 ` Hugh Dickins
2006-09-23 15:36   ` Ulrich Drepper
2006-09-23 15:47     ` Stas Sergeev
2006-09-25  1:12       ` Valdis.Kletnieks
2006-09-25  4:35         ` Stas Sergeev
2006-09-23 15:42   ` Stas Sergeev
2006-09-23 16:04     ` Hugh Dickins
2006-09-23 16:38       ` Stas Sergeev
2006-09-23 18:58       ` Alan Cox
2006-09-24  6:55         ` Stas Sergeev
2006-09-24  9:17           ` Hugh Dickins
2006-09-24 10:00             ` Stas Sergeev
2006-09-24 13:53           ` Alan Cox
2006-09-24 14:54             ` Stas Sergeev
2006-09-24 15:48               ` Ulrich Drepper
2006-09-24 16:31                 ` Stas Sergeev
2006-09-24 16:49                   ` Ulrich Drepper
2006-09-24 17:04                     ` Stas Sergeev
2006-09-24 18:09                     ` Stas Sergeev
2006-09-24 19:14                       ` David Wagner
2006-09-24 19:37                         ` Kyle Moffett
2006-09-24 22:49                           ` David Wagner
2006-09-25 10:53                         ` Pavel Machek
2006-09-25 21:36                           ` David Wagner
2006-09-27 11:51                             ` Pavel Machek
2006-09-24 20:06                       ` Denis Vlasenko
2006-09-24 20:22                         ` Stas Sergeev
2006-09-24 23:04                         ` David Wagner
2006-09-26 19:46                     ` Stas Sergeev
2006-09-27 22:33                       ` Arjan van de Ven
2006-09-27 23:10                         ` David Wagner
2006-09-27 23:38                           ` Jesper Juhl
2006-09-29  1:14                             ` David Wagner
2006-09-28  4:52                         ` Stas Sergeev
2006-09-30  9:42                         ` Stas Sergeev
2006-10-03 15:01                           ` Arjan van de Ven
2006-10-03 17:15                             ` Stas Sergeev
2006-10-03 17:23                               ` Ulrich Drepper
2006-10-03 18:06                                 ` Stas Sergeev
2006-10-03 19:19                                   ` Ulrich Drepper
2006-10-03 19:40                                     ` Stas Sergeev
2006-10-03 19:54                                       ` Arjan van de Ven
2006-10-04 19:36                                         ` Stas Sergeev
2006-10-04 21:31                                           ` David Wagner
2006-10-04  3:11                                     ` David Wagner
2006-10-04  3:51                                       ` Ulrich Drepper
2006-10-04  4:21                                         ` David Wagner
2006-10-04  6:03                                           ` Kyle Moffett
2006-10-04 17:30                                           ` Ulrich Drepper
2006-10-03 18:23                               ` Arjan van de Ven
2006-10-03 18:40                                 ` Stas Sergeev
2006-10-03 18:42                                   ` Arjan van de Ven
2006-10-03 19:07                                     ` Stas Sergeev
2006-10-03 21:00                                       ` Jakub Jelinek
2006-10-04 19:06                                         ` Stas Sergeev
2006-10-06 18:09                                           ` [patch] honour MNT_NOEXEC for access() Stas Sergeev
2006-10-06 21:34                                             ` Alan Cox
2006-10-06 21:17                                               ` Ulrich Drepper
2006-10-07 11:19                                                 ` Stas Sergeev
2006-10-07 15:00                                                   ` David Wagner
2006-10-07 16:31                                                   ` Ulrich Drepper
2006-10-07 19:14                                                     ` Stas Sergeev
2006-10-07 19:36                                                       ` David Wagner
2006-10-08  8:32                                                       ` Arjan van de Ven
2006-10-08  9:11                                                         ` Stas Sergeev
2006-10-08 10:55                                                           ` Arjan van de Ven
2006-10-08 13:46                                                             ` Stas Sergeev
2006-10-09  2:09                                                           ` Horst H. von Brand
2006-10-09  4:40                                                             ` Stas Sergeev
2006-10-07 13:18                                               ` Stas Sergeev
2006-10-08  0:30                                                 ` Jeremy Fitzhardinge
2006-10-08  9:10                                                   ` Stas Sergeev
2006-10-08  9:56                                                     ` Jeremy Fitzhardinge
2006-10-08 10:36                                                       ` Stas Sergeev
2006-10-08 10:39                                                       ` Jesper Juhl
2006-10-08 13:22                                                         ` Stas Sergeev
2006-10-06 22:26                                             ` Jesper Juhl
2006-10-04 19:30                                         ` [patch] remove MNT_NOEXEC check for PROT_EXEC mmaps Stas Sergeev
2006-10-04  3:20                                       ` David Wagner
2006-10-04  3:17                               ` David Wagner
2006-10-04 13:41                                 ` Jeff Dike
2006-10-04 18:02                               ` Jesper Juhl
2006-10-04 19:48                                 ` Stas Sergeev
2006-09-27 19:16                     ` Stas Sergeev [this message]
2006-09-27 20:05                       ` [patch] remove MNT_NOEXEC check for PROT_EXEC MAP_PRIVATE mmaps Hugh Dickins
2006-09-28  4:33                         ` Stas Sergeev
2006-09-28 16:42                           ` Hugh Dickins
2006-09-29  1:41                             ` David Wagner
2006-09-29 20:50                               ` Arjan van de Ven
2006-09-29 16:54                             ` Stas Sergeev
2006-09-24 19:59                   ` [patch] remove MNT_NOEXEC check for PROT_EXEC mmaps Alan Cox
2006-09-24 20:07                     ` Stas Sergeev
2006-09-24  0:53 ` Arjan van de Ven
2006-09-25 17:17   ` Stas Sergeev
2006-09-25 17:43   ` Stas Sergeev
2006-09-25 20:12   ` David Wagner

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=451ACE29.4080005@aknet.ru \
    --to=stsp@aknet.ru \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=arjan@infradead.org \
    --cc=drepper@redhat.com \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).