summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGraff Yang <graff.yang@gmail.com>2009-08-18 23:11:17 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2009-08-19 01:31:13 +0200
commit28d7a6ae92c099d81cbea08c20be0d2cf7ccd7ca (patch)
tree7db56042d0c3e6749c749e1608b3e699485326cf
parentspi_s3c24xx: fix transfer setup code (diff)
downloadlinux-28d7a6ae92c099d81cbea08c20be0d2cf7ccd7ca.tar.xz
linux-28d7a6ae92c099d81cbea08c20be0d2cf7ccd7ca.zip
nommu: check fd read permission in validate_mmap_request()
According to the POSIX (1003.1-2008), the file descriptor shall have been opened with read permission, regardless of the protection options specified to mmap(). The ltp test cases mmap06/07 need this. Signed-off-by: Graff Yang <graff.yang@gmail.com> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Greg Ungerer <gerg@snapgear.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to '')
-rw-r--r--mm/nommu.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mm/nommu.c b/mm/nommu.c
index 28754c40be98..4bde489ec431 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -919,6 +919,10 @@ static int validate_mmap_request(struct file *file,
if (!file->f_op->read)
capabilities &= ~BDI_CAP_MAP_COPY;
+ /* The file shall have been opened with read permission. */
+ if (!(file->f_mode & FMODE_READ))
+ return -EACCES;
+
if (flags & MAP_SHARED) {
/* do checks for writing, appending and locking */
if ((prot & PROT_WRITE) &&