linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
[parent not found: <6qIEW-1Tx-23@gated-at.bofh.it>]
* make PROT_WRITE imply PROT_READ
@ 2006-06-22 17:33 Jason Baron
  0 siblings, 0 replies; 26+ messages in thread
From: Jason Baron @ 2006-06-22 17:33 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel



Hi,

Currently, if i mmap() a file PROT_WRITE only and then first read from it 
and then write to it, i get a SEGV. However, if i write to it first and 
then read from it, i get no SEGV. This seems rather inconsistent.

The current implementation seems to be to make PROT_WRITE imply PROT_READ, 
however it does not quite work correctly. The patch below resolves this 
issue, by explicitly setting the PROT_READ flag when PROT_WRITE is 
requested.

This might appear at first as a possible permissions subversion, as i 
could get PROT_READ on a file that i only have write permission 
to...however, the mmap implementation requires that the file be opened 
with at least read access already. Thus, i don't believe there is any 
issue with regards to permissions.

Another consequenece of this patch is that it forces PROT_READ even for 
architectures that might be able to support it, (I know that x86, x86_64 
and ia64 do not) but i think this is best for portability.

This was originally reported by Doug Chapman.

thanks,

-Jason


Signed-off-by: Jason Baron <jbaron@redhat.com>

--- linux-2.6/mm/mmap.c.bak	2006-06-21 17:07:52.000000000 -0400
+++ linux-2.6/mm/mmap.c	2006-06-21 17:22:54.000000000 -0400
@@ -910,6 +910,13 @@
 		if (!(file && (file->f_vfsmnt->mnt_flags & MNT_NOEXEC)))
 			prot |= PROT_EXEC;
 
+	 /* SuSv3: "if the application requests only PROT_WRITE, the 
+	 *          implementation may also allow read access."
+ 	 */
+
+	if (prot & PROT_WRITE)
+		prot |= PROT_READ;
+
 	if (!len)
 		return -EINVAL;
 

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2006-07-07  2:14 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <fa.PuMM6IwflUYh1MWILO9rb6z4fvY@ifi.uio.no>
2006-06-23  1:24 ` make PROT_WRITE imply PROT_READ Robert Hancock
2006-06-23 13:39   ` Jason Baron
2006-06-23 14:06     ` Arjan van de Ven
2006-06-23 14:05       ` Jason Baron
2006-06-23 14:18         ` Arjan van de Ven
2006-06-24 18:45           ` Ulrich Drepper
2006-06-27  9:56             ` Pavel Machek
2006-06-27 12:18               ` Arjan van de Ven
2006-06-28 16:43               ` Ulrich Drepper
2006-06-28 19:49                 ` Pavel Machek
2006-06-28 20:05                   ` Chase Venters
2006-06-28 23:47                   ` Ulrich Drepper
2006-06-29  7:30                     ` Pavel Machek
2006-06-29 11:58                       ` Alan Cox
2006-06-29 17:20                         ` Pavel Machek
2006-06-29 21:00                           ` Jason Baron
2006-07-07  2:05                             ` Jason Baron
2006-06-30  3:49                       ` Ulrich Drepper
2006-06-29  8:15                 ` Arjan van de Ven
2006-06-30  3:48                   ` Ulrich Drepper
2006-06-30  8:35                     ` Arjan van de Ven
2006-06-30 12:20                       ` Alan Cox
     [not found] <6qIEW-1Tx-23@gated-at.bofh.it>
     [not found] ` <6qIEW-1Tx-21@gated-at.bofh.it>
     [not found]   ` <6qUwd-2Aq-9@gated-at.bofh.it>
     [not found]     ` <6qUwd-2Aq-7@gated-at.bofh.it>
     [not found]       ` <6qUFV-2N8-13@gated-at.bofh.it>
     [not found]         ` <6qUFY-2N8-33@gated-at.bofh.it>
     [not found]           ` <6rlmT-8op-37@gated-at.bofh.it>
     [not found]             ` <6siwJ-3dC-5@gated-at.bofh.it>
     [not found]               ` <6sLoY-4GV-31@gated-at.bofh.it>
     [not found]                 ` <6sZUS-V5-19@gated-at.bofh.it>
     [not found]                   ` <6tib4-2wA-3@gated-at.bofh.it>
     [not found]                     ` <6tmHL-Oq-5@gated-at.bofh.it>
     [not found]                       ` <6tpZ7-5Tj-13@gated-at.bofh.it>
2006-07-01 13:19                         ` Bodo Eggert
2006-07-02  9:56                           ` Alan Cox
2006-07-02 22:04                             ` Bodo Eggert
2006-06-22 17:33 Jason Baron

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).