Skip to content

Commit b79cc87

Browse files
sashalevingregkh
authored andcommitted
iovec: make sure the caller actually wants anything in memcpy_fromiovecend
[ Upstream commit 06ebb06 ] Check for cases when the caller requests 0 bytes instead of running off and dereferencing potentially invalid iovecs. Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent aa85c9d commit b79cc87

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/core/iovec.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ EXPORT_SYMBOL(memcpy_toiovecend);
107107
int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
108108
int offset, int len)
109109
{
110+
/* No data? Done! */
111+
if (len == 0)
112+
return 0;
113+
110114
/* Skip over the finished iovecs */
111115
while (offset >= iov->iov_len) {
112116
offset -= iov->iov_len;

0 commit comments

Comments
 (0)