From: Joe Korty <joe.korty@ccur.com>
To: "David S. Miller" <davem@davemloft.net>,
Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] Fix kfree bug in sendmsg and recvmsg
Date: Wed, 17 Feb 2016 11:38:05 -0500 [thread overview]
Message-ID: <20160217163805.GA15781@zipoli.ccur.com> (raw)
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;
}
next reply other threads:[~2016-02-17 16:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 16:38 Joe Korty [this message]
2016-02-17 16:44 ` [PATCH] Fix kfree bug in sendmsg and recvmsg Al Viro
2016-02-17 16:52 ` Al Viro
2016-02-17 18:29 ` 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=20160217163805.GA15781@zipoli.ccur.com \
--to=joe.korty@ccur.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.