Browse Source

sctp: limit maximum autoclose setsockopt value

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.

Signed-off-by: Andrei Pelinescu-Onciul <andrei@iptel.org>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Andrei Pelinescu-Onciul 15 years ago
parent
commit
f6778aab6c
1 changed files with 3 additions and 0 deletions
  1. 3 0
      net/sctp/socket.c

+ 3 - 0
net/sctp/socket.c

@@ -2086,6 +2086,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;
 }