Skip to content

Commit

Permalink
nommu: check fd read permission in validate_mmap_request()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Graff Yang authored and torvalds committed Aug 18, 2009
1 parent 1915297 commit 28d7a6a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down

0 comments on commit 28d7a6a

Please sign in to comment.