Skip to contentSkip to conversation

sctp: limit maximum autoclose

PATCH Vlad Yasevich 1 participant 1 message Nov 12, 2009 SCTP protocol

lore
Share & tools
lore
#0 lore raw
Quoted 14 lines · Andrei Pelinescu-Onciul

To avoid overflowing the maximum timer interval when transforming the autoclose interval from seconds to jiffies, limit the maximum autoclose value to MAX_SCHEDULE_TIMEOUT/HZ.

---
 net/sctp/socket.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
net/sctp/socket.c +0 -0
index 971890d..2f55723 100644

net/sctp/socket.c static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval, · line 2080

Quoted 9 lines
net/sctp/socket.c +3 -0
@@ -2072,6 +2072,9 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval,
 		return -EINVAL;
 	if (copy_from_user(&sp->autoclose, optval, optlen))
 		return -EFAULT;
+	/* make sure it won't exceed MAX_SCHEDULE_TIMEOUT */
+	if (sp->autoclose > (MAX_SCHEDULE_TIMEOUT / HZ) )
+		sp->autoclose = MAX_SCHEDULE_TIMEOUT / HZ ;
 
 	return 0;
 }

Makes sense. Queued to net-next.

-vlad