From: Sasha Levin <sasha.levin@oracle.com>
To: davem@davemloft.net, jmorris@namei.org, yoshfuji@linux-ipv6.org,
kaber@trash.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Sasha Levin <sasha.levin@oracle.com>
Subject: [PATCH] iovec: make sure the caller actually wants anything in memcpy_fromiovecend
Date: Thu, 31 Jul 2014 23:00:35 -0400 [thread overview]
Message-ID: <1406862035-27818-1-git-send-email-sasha.levin@oracle.com> (raw)
Check for cases when the caller requests 0 bytes instead of running off
and dereferencing potentially invalid iovecs.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
lib/iovec.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/iovec.c b/lib/iovec.c
index 7a7c2da..df3abd1 100644
--- a/lib/iovec.c
+++ b/lib/iovec.c
@@ -85,6 +85,10 @@ EXPORT_SYMBOL(memcpy_toiovecend);
int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
int offset, int len)
{
+ /* No data? Done! */
+ if (len == 0)
+ return 0;
+
/* Skip over the finished iovecs */
while (offset >= iov->iov_len) {
offset -= iov->iov_len;
--
1.7.10.4
next reply other threads:[~2014-08-01 3:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-01 3:00 Sasha Levin [this message]
2014-08-02 22:26 ` [PATCH] iovec: make sure the caller actually wants anything in memcpy_fromiovecend David Miller
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=1406862035-27818-1-git-send-email-sasha.levin@oracle.com \
--to=sasha.levin@oracle.com \
--cc=davem@davemloft.net \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.org \
/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).