linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Josh Hunt <johunt@akamai.com>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] poll() in 32-bit applications does not handle timeout of -1 properly on 64-bit kernels
Date: Tue, 7 Feb 2012 00:38:19 +0000	[thread overview]
Message-ID: <20120207003819.GH23916@ZenIV.linux.org.uk> (raw)
In-Reply-To: <4F306ACA.4090404@akamai.com>

On Mon, Feb 06, 2012 at 06:05:30PM -0600, Josh Hunt wrote:
> We've hit an issue where our 32-bit applications, when running on a
> 64-bit kernel, using poll() and passing in a value of -1 for the timeout
> return after ~49 days (2^32 msec). Instead of waiting indefinitely as it
> is stated they should. Reproducing the issue is trivial. I've
> instrumented the kernel and found we are hitting the case where poll()
> believes we've passed in a positive number and thus creates a timespec,
> etc. Currently poll() is defined in userspace as:
> 
> int poll(struct pollfd *ufds, nfds_t nfds, int timeout);
> 
> but in the kernel timeout is of type long.
> 
> I can think of a few ways to solve this. One, which is the patch I've
> attached, is to change the type of timeout to int in the kernel. I'm not
> certain the ramifications this may have since it's changing a syscall's
> arguments which may be a big no-no :) Another way I am proposing is by
> bounds checking. Currently we do the following:
> 
> if (timeout_msecs >= 0) {
>         to = &end_time;
>         poll_select_set_timeout(to, timeout_msecs / MSEC_PER_SEC,
>                         NSEC_PER_MSEC * (timeout_msecs % MSEC_PER_SEC));
> }
> 
> We could add an upper bound on timeout_msecs to say < 0xffffffff. I'm
> not sure if either is acceptable though.

Or just add compat_sys_poll() with that argument being int and have it call
sys_poll().  The value will be sign-extended...

  reply	other threads:[~2012-02-07  0:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-07  0:05 [RFC PATCH] poll() in 32-bit applications does not handle timeout of -1 properly on 64-bit kernels Josh Hunt
2012-02-07  0:38 ` Al Viro [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-02-07 17:51 Josh Hunt

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=20120207003819.GH23916@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=johunt@akamai.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).