Skip to content

Commit

Permalink
pagemap: return EINVAL, not EIO, for unaligned reads of kpagecount or…
Browse files Browse the repository at this point in the history
… kpageflags

If the user tries to read from a position that is not a multiple of 8, or
read a number of bytes that is not a multiple of 8, they have passed an
invalid argument to read, for the purpose of reading these files.  It's
not an IO error because we didn't encounter any trouble finding the data
they asked for.

Signed-off-by: Thomas Tuttle <ttuttle@google.com>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Thomas Tuttle authored and Linus Torvalds committed Jun 6, 2008
1 parent bbcdac0 commit 4710d1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/proc/proc_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf,
pfn = src / KPMSIZE;
count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
if (src & KPMMASK || count & KPMMASK)
return -EIO;
return -EINVAL;

while (count > 0) {
ppage = NULL;
Expand Down Expand Up @@ -782,7 +782,7 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf,
pfn = src / KPMSIZE;
count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src);
if (src & KPMMASK || count & KPMMASK)
return -EIO;
return -EINVAL;

while (count > 0) {
ppage = NULL;
Expand Down

0 comments on commit 4710d1a

Please sign in to comment.