[NET]: "wrong timeout value" in sk_wait_data() v2
commit7c2d455673d48507a58e8a9c1fda6720085edf12
authorVasily Averin <vvs@sw.ru>
Sun, 22 Jul 2007 15:46:29 +0000 (22 17:46 +0200)
committerAdrian Bunk <bunk@stusta.de>
Sun, 22 Jul 2007 15:46:29 +0000 (22 17:46 +0200)
tree7c1a16dae66256fe06c3313d5ae85b200f274db5
parent28cbc66ccc0fa838789ad01fabee9b25740f7468
[NET]: "wrong timeout value" in sk_wait_data() v2

sys_setsockopt() do not check properly timeout values for
SO_RCVTIMEO/SO_SNDTIMEO, for example it's possible to set negative timeout
values. POSIX do not defines behaviour for sys_setsockopt in case negative
timeouts, but requires that setsockopt() shall fail with -EDOM if the send and
receive timeout values are too big to fit into the timeout fields in the socket
structure.
In current implementation negative timeout can lead to error messages like
"schedule_timeout: wrong timeout value".

Proposed patch:
- checks tv_usec and returns -EDOM if it is wrong
- do not allows to set negative timeout values (sets 0 instead) and outputs
ratelimited information message about such attempts.

Signed-off-By: Vasily Averin <vvs@sw.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
net/core/sock.c