Re: mmap() on cdrom files fails since 2.6.9-rc2-bk2

From: Ingo Molnar
Date: Sun Oct 03 2004 - 06:15:12 EST



* Jean Delvare <khali@xxxxxxxxxxxx> wrote:

> > Capture the strace output.
>
> Here it is (using 2.6.9-rc2-mm4):

> old_mmap(NULL, 42, PROT_READ, MAP_SHARED, 3, 0) = -1 EPERM (Operation not permitted)

could you try the patch below? mmap() done from !pt_gnu_stack binaries
on noexec mounted filesystems indeed could fail due to the extra
PROT_EXEC bit.

Ingo

Signed-off-by: Ingo Molnar <mingo@xxxxxxx>

--- linux/mm/mmap.c.orig
+++ linux/mm/mmap.c
@@ -773,13 +773,6 @@ unsigned long do_mmap_pgoff(struct file
int accountable = 1;
unsigned long charged = 0;

- /*
- * Does the application expect PROT_READ to imply PROT_EXEC:
- */
- if (unlikely((prot & PROT_READ) &&
- (current->personality & READ_IMPLIES_EXEC)))
- prot |= PROT_EXEC;
-
if (file) {
if (is_file_hugepages(file))
accountable = 0;
@@ -791,6 +784,15 @@ unsigned long do_mmap_pgoff(struct file
(file->f_vfsmnt->mnt_flags & MNT_NOEXEC))
return -EPERM;
}
+ /*
+ * Does the application expect PROT_READ to imply PROT_EXEC?
+ *
+ * (the exception is when the underlying filesystem is noexec
+ * 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)))
+ prot |= PROT_EXEC;

if (!len)
return addr;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/