]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
tcp: Add TCP_USER_TIMEOUT negative value check
authorHangbin Liu <liuhangbin@gmail.com>
Thu, 26 Jul 2012 22:52:21 +0000 (22:52 +0000)
committerJerry Snitselaar <jerry.snitselaar@oracle.com>
Sun, 7 Oct 2012 06:28:57 +0000 (23:28 -0700)
[ Upstream commit 42493570100b91ef663c4c6f0c0fdab238f9d3c2 ]

TCP_USER_TIMEOUT is a TCP level socket option that takes an unsigned int. But
patch "tcp: Add TCP_USER_TIMEOUT socket option"(dca43c75) didn't check the negative
values. If a user assign -1 to it, the socket will set successfully and wait
for 4294967295 miliseconds. This patch add a negative value check to avoid
this issue.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 8d7c99de6821880884e6f9ade1c6f269d40ebbae)

Signed-off-by: Jerry Snitselaar <jerry.snitselaar@oracle.com>
net/ipv4/tcp.c

index 56c60a38fe7927ec7c7d2ffe5630e52f8ed0ec0e..faeaf855eb8ab2b12cd94422eafeede40b05c1b7 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;