From: Vadim Lobanov <vlobanov@speakeasy.net>
To: Willy Tarreau <w@1wt.eu>
Cc: Chris Snook <csnook@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2.4.33.2] enforce RLIMIT_NOFILE in poll()
Date: Thu, 31 Aug 2006 21:25:14 -0700 [thread overview]
Message-ID: <200608312125.14564.vlobanov@speakeasy.net> (raw)
In-Reply-To: <20060901034834.GB28317@1wt.eu>
On Thursday 31 August 2006 20:48, Willy Tarreau wrote:
> Hi Chris,
>
> On Thu, Aug 31, 2006 at 09:06:55PM -0400, Chris Snook wrote:
> > From: Chris Snook <csnook@redhat.com>
> >
> > POSIX states that poll() shall fail with EINVAL if nfds > OPEN_MAX. In
> > this context, POSIX is referring to sysconf(OPEN_MAX), which is the value
> > of current->rlim[RLIMIT_NOFILE].rlim_cur, not the compile-time constant
> > which happens to be named OPEN_MAX. The current code will permit polling
> > up to 1024 file descriptors even if RLIMIT_NOFILE is less than 1024,
> > which POSIX forbids. The current code also breaks polling greater than
> > 1024 file descriptors if the process has less than 1024 valid
> > descriptors, even if RLIMIT_NOFILE > 1024. While it is silly to poll
> > duplicate or invalid file descriptors, POSIX permits this, and it worked
> > circa 2.4.18, and currently works up to 1024. This patch directly checks
> > the RLIMIT_NOFILE value, and permits exactly what POSIX suggests, no
> > more, no less.
>
> While I understand that it was a bug before, I fear that it could break
> existing apps. Are you aware of some apps which do not work as expected
> because of this bug ? If not, I'd prefer to wait for some feedback from
> 2.6 with this fix before applying it (or maybe you're already using it
> in RHEL with success ?).
I submitted a similar but different patch for this very same issue against the
2.6 kernel. It's currently residing in the -mm tree. Andrew Morton is
somewhat reticent (and understandably so) to push it quickly into the vanilla
tree; but, for what it's worth, I've yet to hear -- either directly or
indirectly -- of any application breakages caused by this fix.
> Thanks,
> Willy
>
> > Signed-off-by: Chris Snook <csnook@redhat.com>
> > ---
> >
> > diff -urNp linux-2.4.33.2-orig/fs/select.c
> > linux-2.4.33.2-patch/fs/select.c ---
> > linux-2.4.33.2-orig/fs/select.c 2006-08-22 16:13:54.000000000 -0400 +++
> > linux-2.4.33.2-patch/fs/select.c 2006-08-31 13:43:39.000000000 -0400 @@
> > -417,7 +417,7 @@ asmlinkage long sys_poll(struct pollfd *
> > int nchunks, nleft;
> >
> > /* Do a sanity check on nfds ... */
> > - if (nfds > current->files->max_fdset && nfds > OPEN_MAX)
> > + if (nfds > current->rlim[RLIMIT_NOFILE].rlim_cur)
> > return -EINVAL;
> >
> > if (timeout) {
>
-- Vadim Lobanov
next prev parent reply other threads:[~2006-09-01 4:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-01 1:06 Chris Snook
2006-09-01 3:48 ` Willy Tarreau
2006-09-01 4:25 ` Vadim Lobanov [this message]
2006-09-01 6:08 ` Chris Snook
2006-09-01 16:03 ` Chris Snook
2006-09-01 19:31 ` Willy Tarreau
2006-09-01 21:24 ` Chris Snook
2006-09-01 20:04 ` Willy Tarreau
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=200608312125.14564.vlobanov@speakeasy.net \
--to=vlobanov@speakeasy.net \
--cc=csnook@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=w@1wt.eu \
/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®