From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: v9fs-developer@lists.sourceforge.net
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Sanchit Garg <sancgarg@linux.vnet.ibm.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [PATCH 2/2] net/9p: Return error on read with NULL buffer
Date: Mon, 18 Oct 2010 20:10:53 +0530 [thread overview]
Message-ID: <1287412853-24700-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1287412853-24700-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
From: Sanchit Garg <sancgarg@linux.vnet.ibm.com>
This patch ensures that a read(fd, NULL, 0 ) returns EFAULT on a 9p file.
Signed-off-by: Sanchit Garg <sancgarg@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
net/9p/client.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/9p/client.c b/net/9p/client.c
index e141e46..d5344d8 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -1313,6 +1313,11 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
rsize = fid->iounit;
if (!rsize || rsize > clnt->msize-P9_IOHDRSZ)
rsize = clnt->msize - P9_IOHDRSZ;
+ /*
+ * A read with NULL user buffer cause EFAULT error
+ */
+ if (!data && !udata)
+ return -EFAULT;
if (count < rsize)
rsize = count;
@@ -1333,16 +1338,13 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
if (data) {
memmove(data, dataptr, count);
- }
-
- if (udata) {
+ } else {
err = copy_to_user(udata, dataptr, count);
if (err) {
err = -EFAULT;
goto free_and_error;
}
}
-
p9_free_req(clnt, req);
return count;
--
1.7.1
next prev parent reply other threads:[~2010-10-18 14:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-18 14:40 [PATCH 1/2] net/9p: Return error if we fail to encode protocol data Aneesh Kumar K.V
2010-10-18 14:40 ` Aneesh Kumar K.V [this message]
2010-10-23 19:59 ` [PATCH 2/2] net/9p: Return error on read with NULL buffer Brad Boyer
2010-10-24 14:32 ` Aneesh Kumar K. V
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=1287412853-24700-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sancgarg@linux.vnet.ibm.com \
--cc=v9fs-developer@lists.sourceforge.net \
/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.