[PATCH net-next 3/5] sctp: fix the length check in sctp_getsockopt_maxburst()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Vlad Yasevich
Date: Monday, March 2, 2009 - 12:46 pm

From: Wei Yongjun <yjwei@cn.fujitsu.com>

The code in sctp_getsockopt_maxburst() doesn't allow len to be larger
then struct sctp_assoc_value, which is a common case where app writers
just pass down the sizeof(buf) or something similar.

This patch fix the problem.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
---
 net/sctp/socket.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 4bc558c..bbd3cd2 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -5286,7 +5286,8 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len,
 		printk(KERN_WARNING
 		   "SCTP: Use struct sctp_assoc_value instead\n");
 		params.assoc_id = 0;
-	} else if (len == sizeof (struct sctp_assoc_value)) {
+	} else if (len >= sizeof(struct sctp_assoc_value)) {
+		len = sizeof(struct sctp_assoc_value);
 		if (copy_from_user(&params, optval, len))
 			return -EFAULT;
 	} else
-- 
1.5.4.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH net-next 0/5] sctp: Bug fixes, Vlad Yasevich, (Mon Mar 2, 12:46 pm)
[PATCH net-next 3/5] sctp: fix the length check in sctp_ge ..., Vlad Yasevich, (Mon Mar 2, 12:46 pm)
Re: [PATCH net-next 0/5] sctp: Bug fixes, David Miller, (Mon Mar 2, 11:56 pm)