提交 21ff8216 编写于 作者: D David Howells 提交者: Linus Torvalds

[PATCH] NOMMU: Fix execution off of ramfs with mmap()

Fix execution through the FDPIC binfmt of programs stored on ramfs by
preventing the ramfs mmap() returning successfully on a private mapping of
a ramfs file.  This causes NOMMU mmap to make a copy of the mapped portion
of the file and map that instead.

This could be improved by granting direct mapping access to read-only
private mappings for which the data is stored on a contiguous run of pages.
 However, this is only likely to be the case if the file was extended with
truncate before being written.

ramfs is left to map the file directly for shared mappings so that SYSV IPC
and POSIX shared memory both still work.
Signed-off-by: NDavid Howells <dhowells@redhat.com>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 9dec17eb
...@@ -283,9 +283,9 @@ unsigned long ramfs_nommu_get_unmapped_area(struct file *file, ...@@ -283,9 +283,9 @@ unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
/*****************************************************************************/ /*****************************************************************************/
/* /*
* set up a mapping * set up a mapping for shared memory segments
*/ */
int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma) int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma)
{ {
return 0; return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册