public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/nommu.c: check read permission in validate_mmap_request()
@ 2009-08-14  3:19 graff.yang
  2009-08-14  4:57 ` Paul Mundt
  0 siblings, 1 reply; 2+ messages in thread
From: graff.yang @ 2009-08-14  3:19 UTC (permalink / raw)
  To: dhowells, linux-kernel; +Cc: akpm, uclinux-dist-devel, Graff Yang

From: Graff Yang <graff.yang@gmail.com>

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.

Signed-off-by: Graff Yang <graff.yang@gmail.com>
---
 mm/nommu.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/mm/nommu.c b/mm/nommu.c
index 53cab10..ac13b23 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -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) &&
-- 
1.6.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-14  4:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-14  3:19 [PATCH] mm/nommu.c: check read permission in validate_mmap_request() graff.yang
2009-08-14  4:57 ` Paul Mundt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox