Skip to contentSkip to conversation

sctp: check len in sctp_getsockopt_assoc_stats()

PATCH In review Dan Carpenter 2 participants 2 messages Feb 27, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sctp: check len in sctp_getsockopt_assoc_stats()

This check is missing an upper bound.

---
This should go in 3.8 -stable as well.

net/sctp/socket.c +2 -0
index c99458d..fbd8386 100644
@@ -5652,6 +5652,8 @@ static int sctp_getsockopt_assoc_stats(struct sock *sk, int len,
 	/* User must provide at least the assoc id */
 	if (len < sizeof(sctp_assoc_t))
 		return -EINVAL;
+	if (len > sizeof(struct sctp_assoc_stats))
+		len = sizeof(struct sctp_assoc_stats);
 
 	if (copy_from_user(&sas, optval, len))
 		return -EFAULT;