From: Nish Aravamudan <nish.aravamudan@gmail.com>
To: "linux-os (Dick Johnson)" <linux-os@analogic.com>
Cc: Ram Gupta <ram.gupta5@gmail.com>,
Linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: negative timeout can be set up by setsockopt system call
Date: Fri, 4 Nov 2005 15:18:51 -0800 [thread overview]
Message-ID: <29495f1d0511041518t3cd22b4eq29b32b8545df969f@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0511041658240.13855@chaos.analogic.com>
On 11/4/05, linux-os (Dick Johnson) <linux-os@analogic.com> wrote:
>
> On Fri, 4 Nov 2005, Ram Gupta wrote:
>
> > I observed that the the setsockopt system call can setup negative
> > timeout. As a matter of fact the function sock_set_timeout checks for
> > zero timeout but does not check for negative timeouts. I tested this
> > against 2.6.14 kernel but it is so in all previous release also. So I
> > am wondering if it is a bug or there is some reason for keeping it that
> > way which I am missing.
> >
> > Regards
> > Ram gupta
>
> As a parameter it takes a void pointer to the value plus a
> length of the object to which the value points. Given this,
> I don't understand "negative". The pointer can point to
> anything of a specified size so it doesn't have a sense
> of +/-.
Huh?
In Ram's specific case, I think, the call path is sys_setsockopt() ->
sock_setsockopt() -> sock_set_timeout, which has a definition of:
static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen)
where optval is the same optval in sys_setsockopt():
sys_setsockopt(int fd, int level, int optname, char __user *optval, int optlen)
and is a pointer to a userspace timeval structure, in this case.
timeval's have two members, both of which are signed, so it makes
perfect sense for one of them to be (potentially) negative:
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
(time_t --> __kernel_time_t --> long on all archs; suseconds_t -->
__kernel_suseconds_t --> int or long on all archs)
Ram, what is the expected behavior of negative values in the timeval?
And what are you seeing happen right now?
As of 2.6.14, looks like we convert any non-zero values into jiffies
and store them in sk->sk_{rcv,snd}timeo...
> If the socket call itself checked for sign it would
> severly limit what options could be adjusted. Perhaps
> the SO_SNDTIMEO/SO_RCVTIMEO might do some checking, but
> I think it's valid to set the timeout to -1, meaning it
> never times-out.
This could be, and I think is what Ram was asking about -- I've asked
for some clarification.
Thanks,
Nish
next prev parent reply other threads:[~2005-11-04 23:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-04 20:27 Ram Gupta
2005-11-04 22:07 ` linux-os (Dick Johnson)
2005-11-04 23:18 ` Nish Aravamudan [this message]
2005-11-07 14:42 Ram Gupta
2005-11-07 15:04 ` Nish Aravamudan
2005-11-07 19:29 Ram Gupta
2005-11-07 19:44 ` Nish Aravamudan
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=29495f1d0511041518t3cd22b4eq29b32b8545df969f@mail.gmail.com \
--to=nish.aravamudan@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.com \
--cc=ram.gupta5@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®