diff options
author | Hangbin Liu <liuhangbin@gmail.com> | 2012-07-26 18:52:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-27 16:45:50 -0400 |
commit | 42493570100b91ef663c4c6f0c0fdab238f9d3c2 (patch) | |
tree | a97aede6490c7eea90b83b1bf3bd26037e5485c9 /net/ipv4/tcp.c | |
parent | b387e41e523c1aa347cff055455d0dd129357df4 (diff) |
tcp: Add TCP_USER_TIMEOUT negative value check
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>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 581ecf02c6b5..e7e6eeae49c0 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -2681,7 +2681,10 @@ static int do_tcp_setsockopt(struct sock *sk, int level, | |||
2681 | /* Cap the max timeout in ms TCP will retry/retrans | 2681 | /* Cap the max timeout in ms TCP will retry/retrans |
2682 | * before giving up and aborting (ETIMEDOUT) a connection. | 2682 | * before giving up and aborting (ETIMEDOUT) a connection. |
2683 | */ | 2683 | */ |
2684 | icsk->icsk_user_timeout = msecs_to_jiffies(val); | 2684 | if (val < 0) |
2685 | err = -EINVAL; | ||
2686 | else | ||
2687 | icsk->icsk_user_timeout = msecs_to_jiffies(val); | ||
2685 | break; | 2688 | break; |
2686 | default: | 2689 | default: |
2687 | err = -ENOPROTOOPT; | 2690 | err = -ENOPROTOOPT; |