netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iovec: make sure the caller actually wants anything in memcpy_fromiovecend
@ 2014-08-01  3:00 Sasha Levin
  2014-08-02 22:26 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Sasha Levin @ 2014-08-01  3:00 UTC (permalink / raw)
  To: davem, jmorris, yoshfuji, kaber; +Cc: netdev, linux-kernel, Sasha Levin

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iovec: make sure the caller actually wants anything in memcpy_fromiovecend
  2014-08-01  3:00 [PATCH] iovec: make sure the caller actually wants anything in memcpy_fromiovecend Sasha Levin
@ 2014-08-02 22:26 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-08-02 22:26 UTC (permalink / raw)
  To: sasha.levin; +Cc: jmorris, yoshfuji, kaber, netdev, linux-kernel

From: Sasha Levin <sasha.levin@oracle.com>
Date: Thu, 31 Jul 2014 23:00:35 -0400

> 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>

Applied, thanks.

BTW, if you look at the function above this one (memcpy_toiovecend) it avoids
this issue by encompassing all of the logic in a top-level loop which terminates
when len <= 0.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-02 22:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-01  3:00 [PATCH] iovec: make sure the caller actually wants anything in memcpy_fromiovecend Sasha Levin
2014-08-02 22:26 ` David Miller

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).