From: Shiraz Hashim <shashim@codeaurora.org>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, oleg@redhat.com, gorcunov@openvz.org,
linux-kernel@vger.kernel.org,
Shiraz Hashim <shashim@codeaurora.org>
Subject: [PATCH 1/1] mm: pagemap: limit scan to virtual region being asked
Date: Tue, 13 Jan 2015 17:57:04 +0530 [thread overview]
Message-ID: <1421152024-6204-1-git-send-email-shashim@codeaurora.org> (raw)
pagemap_read scans through the virtual address space of a
task till it prepares 'count' pagemaps or it reaches end
of task.
This presents a problem when the page walk doesn't happen
for vma with VM_PFNMAP set. In which case walk is silently
skipped and no pagemap is prepare, in turn making
pagemap_read to scan through task end, even crossing beyond
'count', landing into a different vma region. This leads to
wrong presentation of mappings for that vma.
Fix this by limiting end_vaddr to the end of the virtual
address region being scanned.
Signed-off-by: Shiraz Hashim <shashim@codeaurora.org>
---
fs/proc/task_mmu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 246eae8..04362e4 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1270,7 +1270,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
src = *ppos;
svpfn = src / PM_ENTRY_BYTES;
start_vaddr = svpfn << PAGE_SHIFT;
- end_vaddr = TASK_SIZE_OF(task);
+ end_vaddr = start_vaddr + ((count / PM_ENTRY_BYTES) << PAGE_SHIFT);
+ if ((end_vaddr > TASK_SIZE_OF(task)) || (end_vaddr < start_vaddr))
+ end_vaddr = TASK_SIZE_OF(task);
/* watch out for wraparound */
if (svpfn > TASK_SIZE_OF(task) >> PAGE_SHIFT)
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2015-01-13 12:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-13 12:27 Shiraz Hashim [this message]
2015-01-14 1:08 ` [PATCH 1/1] mm: pagemap: limit scan to virtual region being asked Naoya Horiguchi
2015-01-18 17:13 ` Shiraz Hashim
2015-02-11 22:09 ` Andrew Morton
2015-02-11 23:16 ` Naoya Horiguchi
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=1421152024-6204-1-git-send-email-shashim@codeaurora.org \
--to=shashim@codeaurora.org \
--cc=akpm@linux-foundation.org \
--cc=gorcunov@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).