From: "Thomas Tuttle" <ttuttle@google.com>
To: mpm@selenic.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] pagemap: Make pagemap_read enforce reading in multiples of 8
Date: Thu, 5 Jun 2008 11:06:02 -0400 [thread overview]
Message-ID: <4ca0a85e0806050806r38de18dft8927e093a8e47abd@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 164 bytes --]
Since kpagecount and kpageflags require reads in multiples of 8, and
it simplifies add_to_pagemap significantly, I added the same
requirement to /proc/pid/pagemap.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-Make-pagemap_read-enforce-reading-in-multiples-of-8.patch --]
[-- Type: text/x-patch; name=0003-Make-pagemap_read-enforce-reading-in-multiples-of-8.patch, Size: 1800 bytes --]
From 25908731b67069d6cf56d8af522b55479ea75736 Mon Sep 17 00:00:00 2001
From: Thomas Tuttle <ttuttle@google.com>
Date: Thu, 5 Jun 2008 10:45:55 -0400
Subject: [PATCH] Make pagemap_read enforce reading in multiples of 8.
Previously, /proc/pid/pagemap would allow reads of lengths that were not
multiples of 8 to succeed (and would return correct data), but had no way
of reading the remainder of the partial value returned.
/proc/kpage{count,flags} are also arrays of u64s, and they require that
reads are a multiple of 8. This patch makes /proc/pid/pagemap consistent.
Signed-off-by: Thomas Tuttle <ttuttle@google.com>
---
fs/proc/task_mmu.c | 18 ++++--------------
1 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 9915202..3f6d680 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -519,21 +519,11 @@ struct pagemapread {
static int add_to_pagemap(unsigned long addr, u64 pfn,
struct pagemapread *pm)
{
- /*
- * Make sure there's room in the buffer for an
- * entire entry. Otherwise, only copy part of
- * the pfn.
- */
- if (pm->out + PM_ENTRY_BYTES >= pm->end) {
- if (copy_to_user(pm->out, &pfn, pm->end - pm->out))
- return -EFAULT;
- pm->out = pm->end;
- return PM_END_OF_BUFFER;
- }
-
if (copy_to_user(pm->out, &pfn, PM_ENTRY_BYTES))
return -EFAULT;
pm->out += PM_ENTRY_BYTES;
+ if (pm->out >= pm->end)
+ return PM_END_OF_BUFFER;
return 0;
}
@@ -633,8 +623,8 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
goto out_task;
ret = -EINVAL;
- /* file position must be aligned */
- if (*ppos % PM_ENTRY_BYTES)
+ /* file position and count must be aligned */
+ if ((*ppos % PM_ENTRY_BYTES) || (count % PM_ENTRY_BYTES))
goto out_task;
ret = 0;
--
1.5.3.6
next reply other threads:[~2008-06-05 15:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-05 15:06 Thomas Tuttle [this message]
2008-06-05 16:03 ` Matt Mackall
2008-06-05 16:05 ` Thomas Tuttle
2008-06-05 16:09 ` Matt Mackall
2008-06-05 16:14 ` Thomas Tuttle
2008-06-05 16:21 ` Matt Mackall
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=4ca0a85e0806050806r38de18dft8927e093a8e47abd@mail.gmail.com \
--to=ttuttle@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.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
all inboxes | Powered by JetHome®