summaryrefslogtreecommitdiff
path: root/net/compat.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2013-11-27 12:40:21 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-08 15:29:13 (GMT)
commit5bca4e493175cd62bb92af685262b11bb7d2ffba (patch)
treed027e0f6e77d72fa2c86ee7002ae5cdf5bd43552 /net/compat.c
parentd4cbc4a91331e0fa5819cdf4267be4f07185eef6 (diff)
downloadlinux-fsl-qoriq-5bca4e493175cd62bb92af685262b11bb7d2ffba.tar.xz
net: clamp ->msg_namelen instead of returning an error
[ Upstream commit db31c55a6fb245fdbb752a2ca4aefec89afabb06 ] If kmsg->msg_namelen > sizeof(struct sockaddr_storage) then in the original code that would lead to memory corruption in the kernel if you had audit configured. If you didn't have audit configured it was harmless. There are some programs such as beta versions of Ruby which use too large of a buffer and returning an error code breaks them. We should clamp the ->msg_namelen value instead. Fixes: 1661bf364ae9 ("net: heap overflow in __audit_sockaddr()") Reported-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Tested-by: Eric Wong <normalperson@yhbt.net> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/compat.c')
-rw-r--r--net/compat.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/compat.c b/net/compat.c
index 618c6a8..dd32e34 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -72,7 +72,7 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
__get_user(kmsg->msg_flags, &umsg->msg_flags))
return -EFAULT;
if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
- return -EINVAL;
+ kmsg->msg_namelen = sizeof(struct sockaddr_storage);
kmsg->msg_name = compat_ptr(tmp1);
kmsg->msg_iov = compat_ptr(tmp2);
kmsg->msg_control = compat_ptr(tmp3);