Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ba78073e6f70cd9c64a478a9bd901d7c8736cfbc
Commit:     ba78073e6f70cd9c64a478a9bd901d7c8736cfbc
Parent:     c883f215a23a9352097b8d17fb8dae22ff134a14
Author:     Vasily Averin <[EMAIL PROTECTED]>
AuthorDate: Thu May 24 16:58:54 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Thu May 24 16:58:54 2007 -0700

    [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 <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/core/sock.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 22183c2..7e51d3a 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -206,7 +206,19 @@ static int sock_set_timeout(long *timeo_p, char __user 
*optval, int optlen)
                return -EINVAL;
        if (copy_from_user(&tv, optval, sizeof(tv)))
                return -EFAULT;
-
+       if (tv.tv_usec < 0 || tv.tv_usec >= USEC_PER_SEC)
+               return -EDOM;
+
+       if (tv.tv_sec < 0) {
+               static int warned = 0;
+               *timeo_p = 0;
+               if (warned < 10 && net_ratelimit())
+                       warned++;
+                       printk(KERN_INFO "sock_set_timeout: `%s' (pid %d) "
+                              "tries to set negative timeout\n",
+                               current->comm, current->pid);
+               return 0;
+       }
        *timeo_p = MAX_SCHEDULE_TIMEOUT;
        if (tv.tv_sec == 0 && tv.tv_usec == 0)
                return 0;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to