Skip to contentSkip to conversation

mm/nommu.c: check read permission in validate_mmap_request()

PATCH In review [email protected] 2 participants 2 messages Aug 14, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/nommu.c: check read permission in validate_mmap_request()

From: Graff Yang <[email protected]>

According to the POSIX (1003.1-2008), the file shall have been opened with read permission, regardless of the protection options specified. The ltp test cases mmap06/07 need this.

---
 mm/nommu.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
mm/nommu.c +4 -0
index 53cab10..ac13b23 100644
@@ -922,6 +922,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) &&
Signature · 1 line
1.6.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Fri, Aug 14, 2009 at 11:19:21AM +0800, [email protected] wrote:

From: Graff Yang <[email protected]>

According to the POSIX (1003.1-2008), the file shall have been opened with read permission, regardless of the protection options specified. The ltp test cases mmap06/07 need this.

Looks good. This brings it more in line with MMU Linux anyways, so it's worthwhile regardless.