From: <graff.yang@gmail.com>
To: dhowells@redhat.com, linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org,
uclinux-dist-devel@blackfin.uclinux.org,
Graff Yang <graff.yang@gmail.com>
Subject: [PATCH] mm/nommu.c: check read permission in validate_mmap_request()
Date: Fri, 14 Aug 2009 11:19:21 +0800 [thread overview]
Message-ID: <1250219961-11681-1-git-send-email-graff.yang@gmail.com> (raw)
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
next reply other threads:[~2009-08-14 3:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-14 3:19 graff.yang [this message]
2009-08-14 4:57 ` [PATCH] mm/nommu.c: check read permission in validate_mmap_request() Paul Mundt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1250219961-11681-1-git-send-email-graff.yang@gmail.com \
--to=graff.yang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=uclinux-dist-devel@blackfin.uclinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.