sctp: limit maximum autoclose setsockopt value
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Mon, 23 Nov 2009 20:54:01 +0000 (15:54 -0500)
committerVlad Yasevich <vladislav.yasevich@hp.com>
Mon, 23 Nov 2009 20:54:01 +0000 (15:54 -0500)
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>
net/sctp/socket.c

index d2681a6bc6fa687499de4948e2b9af88f59f67af..71513b3926a5e19a1eed8250988d66f71dbfe714 100644 (file)
@@ -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;
 }