Commit 28d7a6ae92c099d81cbea08c20be0d2cf7ccd7ca
Committed by
Linus Torvalds
1 parent
1915297566
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>
Showing 1 changed file with 4 additions and 0 deletions Side-by-side Diff
mm/nommu.c
... | ... | @@ -919,6 +919,10 @@ |
919 | 919 | if (!file->f_op->read) |
920 | 920 | capabilities &= ~BDI_CAP_MAP_COPY; |
921 | 921 | |
922 | + /* The file shall have been opened with read permission. */ | |
923 | + if (!(file->f_mode & FMODE_READ)) | |
924 | + return -EACCES; | |
925 | + | |
922 | 926 | if (flags & MAP_SHARED) { |
923 | 927 | /* do checks for writing, appending and locking */ |
924 | 928 | if ((prot & PROT_WRITE) && |