summaryrefslogtreecommitdiff
path: root/net/ipv4
diff options
context:
space:
mode:
authorHangbin Liu <liuhangbin@gmail.com>2012-07-26 22:52:21 +0000
committerBen Hutchings <ben@decadent.org.uk>2012-08-19 18:15:24 +0100
commitdf7ba2e6620095039c0aa42af7de1ec565eca2eb (patch)
tree8bbbb161c103084ff8f3f046f4670db0d8a1a1d2 /net/ipv4
parent761bfbd36cbff87f2d04502b66a363507a08ad33 (diff)
tcp: Add TCP_USER_TIMEOUT negative value check
[ 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: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/tcp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 11ba9223ee38..ad466a7f8bc6 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2391,7 +2391,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;