linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix kfree bug in sendmsg and recvmsg
@ 2016-02-17 16:38 Joe Korty
  2016-02-17 16:44 ` Al Viro
  2016-02-17 18:29 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Joe Korty @ 2016-02-17 16:38 UTC (permalink / raw)
  To: David S. Miller, Alexander Viro; +Cc: Linux Kernel Mailing List

Fix kfree bug in recvmsg and sendmsg.

We cannot kfree(iov) when iov points to an array on the
stack, as that has the potential of corrupting memory.

So re-introduce the if-stmt that used to protect kfree
from this condition, code that was removed as part of
a larger set of changes made by git commit da184284.

Signed-off-by: Joe Korty <joe.korty@ccur.com>

Index: b/net/socket.c
===================================================================
--- a/net/socket.c
+++ b/net/socket.c
@@ -1960,7 +1960,8 @@ out_freectl:
 	if (ctl_buf != ctl)
 		sock_kfree_s(sock->sk, ctl_buf, ctl_len);
 out_freeiov:
-	kfree(iov);
+	if (iov != iovstack)
+		kfree(iov);
 	return err;
 }
 
@@ -2125,7 +2126,8 @@ static int ___sys_recvmsg(struct socket 
 	err = len;
 
 out_freeiov:
-	kfree(iov);
+	if (iov != iovstack)
+		kfree(iov);
 	return err;
 }
 

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

end of thread, other threads:[~2016-02-17 18:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-17 16:38 [PATCH] Fix kfree bug in sendmsg and recvmsg Joe Korty
2016-02-17 16:44 ` Al Viro
2016-02-17 16:52   ` Al Viro
2016-02-17 18:29 ` 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).