tcp: Add TCP_USER_TIMEOUT negative value check
[firefly-linux-kernel-4.4.55.git] / net / ipv4 / tcp.c
index 6db041d3284c752d8e94b9b770e039da1f5240ff..b6ec23c7ffc53b382963bc01ec96d97e8e3787af 100644 (file)
@@ -2394,7 +2394,10 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
                /* Cap the max timeout in ms TCP will retry/retrans
                 * before giving up and aborting (ETIMEDOUT) a connection.
                 */
-               icsk->icsk_user_timeout = msecs_to_jiffies(val);
+               if (val < 0)
+                       err = -EINVAL;
+               else
+                       icsk->icsk_user_timeout = msecs_to_jiffies(val);
                break;
        default:
                err = -ENOPROTOOPT;