From: Eric Dumazet <dada1@cosmosbay.com>
To: Vasily Averin <vvs@sw.ru>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, Andrew Morton <akpm@osdl.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
devel@openvz.org
Subject: Re: [PATCH netdev] "wrong timeout value" in sk_wait_data()
Date: Thu, 24 May 2007 06:36:05 +0200 [thread overview]
Message-ID: <46551635.30809@cosmosbay.com> (raw)
In-Reply-To: <465512EB.4000808@sw.ru>
Vasily Averin a écrit :
> 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>
>
> diff --git a/net/core/sock.c b/net/core/sock.c
> index 22183c2..27d7a46 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 >= 1000000)
> + return -EDOM;
Please use USEC_PER_SEC instead of 1000000
> +
> + 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;
>
next prev parent reply other threads:[~2007-05-24 4:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-24 4:22 [PATCH netdev] "wrong timeout value" in sk_wait_data() Vasily Averin
2007-05-24 4:36 ` Eric Dumazet [this message]
2007-05-24 5:23 ` [PATCH netdev] "wrong timeout value" in sk_wait_data() v2 Vasily Averin
2007-05-24 23:59 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46551635.30809@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=akpm@osdl.org \
--cc=davem@davemloft.net \
--cc=devel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vvs@sw.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.