NOMMU: Check fd read permission in validate_mmap_request()
Subsystems (2)
PATCH 1/1 NOMMU: Check fd read permission in validate_mmap_request()
From: Graff Yang <[email protected]>
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 <[email protected]>
Acked-by Paul Mundt <[email protected]>
Signed-off-by David Howells <[email protected]>
---
mm/nommu.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
mm/nommu.c +4 -0
@@ -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) &&