Thread (116 messages) 116 messages, 6 authors, 2014-08-26
STALE4330d

[PATCH 3.12 041/104] iovec: make sure the caller actually wants anything in memcpy_fromiovecend

From: Jiri Slaby <hidden>
Date: 2014-08-20 12:06:11
Also in: lkml
Subsystem: networking [general], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

From: Sasha Levin <redacted>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

[ Upstream commit 06ebb06d49486676272a3c030bfeef4bd969a8e6 ]

Check for cases when the caller requests 0 bytes instead of running off
and dereferencing potentially invalid iovecs.

Signed-off-by: Sasha Levin <redacted>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <redacted>
---
 net/core/iovec.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/net/core/iovec.c b/net/core/iovec.c
index dcf0bd5fbc20..8254497bda65 100644
--- a/net/core/iovec.c
+++ b/net/core/iovec.c
@@ -107,6 +107,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;
-- 
2.0.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help