netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]: SCTP length validation.
@ 2008-06-21  5:12 David Miller
  2008-06-21 15:55 ` Vlad Yasevich
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2008-06-21  5:12 UTC (permalink / raw)
  To: netdev; +Cc: linux-sctp, vladislav.yasevich


I just checked in the following SCTP bug fix to net-2.6 and will make
sure it gets into -stable as well.

sctp: Make sure N * sizeof(union sctp_addr) does not overflow.

As noticed by Gabriel Campana, the kmalloc() length arg
passed in by sctp_getsockopt_local_addrs_old() can overflow
if ->addr_num is large enough.

Therefore, enforce an appropriate limit.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/sctp/socket.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index e7e3baf..0dbcde6 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4401,7 +4401,9 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
 	if (copy_from_user(&getaddrs, optval, len))
 		return -EFAULT;
 
-	if (getaddrs.addr_num <= 0) return -EINVAL;
+	if (getaddrs.addr_num <= 0 ||
+	    getaddrs.addr_num >= (INT_MAX / sizeof(union sctp_addr)))
+		return -EINVAL;
 	/*
 	 *  For UDP-style sockets, id specifies the association to query.
 	 *  If the id field is set to the value '0' then the locally bound
-- 
1.5.6


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

end of thread, other threads:[~2008-06-23 21:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-21  5:12 [PATCH]: SCTP length validation David Miller
2008-06-21 15:55 ` Vlad Yasevich
2008-06-22 19:32   ` David Miller
2008-06-23 15:59     ` Vlad Yasevich
2008-06-23 21:42       ` 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).