mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vitaly Mayatskikh <v.mayatskih@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Thomas Tuttle <ttuttle@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] pagemap: require aligned-length, non-null reads of /proc/pid/pagemap
Date: Mon, 20 Apr 2009 16:58:32 +0200	[thread overview]
Message-ID: <87eivn5q3r.wl%vmayatsk@redhat.com> (raw)

The intention of commit aae8679b0ebcaa92f99c1c3cb0cd651594a43915 was to
force reads of /proc/pid/pagemap to be a multiple of 8 bytes, but now it 
allows to read 0 bytes, which actually puts some data to user's buffer.
According to POSIX, if count is zero, read() should return zero and has
no other results.

Signed-off-by: Vitaly Mayatskikh <v.mayatskih@gmail.com>

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 39e4ad4..6f61b7c 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -665,6 +665,10 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 		goto out_task;
 
 	ret = 0;
+
+	if (!count)
+		goto out_task;
+
 	mm = get_task_mm(task);
 	if (!mm)
 		goto out_task;

-- 
wbr, Vitaly

                 reply	other threads:[~2009-04-20 14:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87eivn5q3r.wl%vmayatsk@redhat.com \
    --to=v.mayatskih@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ttuttle@google.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®