public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Peter Hartley" <pdh@utter.chaos.org.uk>
To: "Andreas Dilger" <adilger@clusterfs.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: setrlimit and RLIM_INFINITY causing fsck failure, 2.4.18
Date: Tue, 19 Mar 2002 18:20:53 -0000	[thread overview]
Message-ID: <008301c1cf72$ce5801a0$2701230a@electronic> (raw)
In-Reply-To: <006701c1cf6d$d9701230$2701230a@electronic> <20020319141554.GL470@turbolinux.com>

Andreas Dilger wrote:
> On Mar 19, 2002  17:45 -0000, Peter Hartley wrote:
> > In particular, this means that an e2fsck 1.27 built against such a glibc
> > will fail with SIGXFS every time on any block device bigger than
2Gbytes.
> > This is because:
> >
> >  * e2fsck calls setrlimit(RLIMIT_FSIZE, RLIM_INFINITY) in
> >    an attempt to unset the limit. RLIM_INFINITY here is
> >    0xFFFFFFFF. This is IMO the Right Thing.
>
> It is only the right thing if the original limit was not 0xFFFFFFFF.
> Otherwise, it is just adding to the problem, because the problem only
> happens when you try to SET the limit.

True. (Old programs *will* perceive the value as 0xFFFFFFFF if it is
RLIM_INFINITY; the kernel clips it to 0x7FFFFFFF in sys_old_getrlimit() but
glibc expands it again in __new_getrlimit().)

> > Surely the only Right Things to do in the kernel are (a) invent a new
> > setrlimit call that corrects the RLIM_INFINITY value, or (b) have the
> > current setrlimit call correct the RLIM_INFINITY value unconditionally.
>
> (c) rlimit should not apply to block devices.
>
> There were patches for this floating around, and I thought they made it
> into 2.4.18, but they did not.

Looking a bit closer at the particular SIGXFS that kills fsck (in
generic_file_write) there's some S_ISBLK stuff going on just below.

Is the fix just as simple as: (untested) (and with a mailer than mangles
tabs)

--- filemap.c~ Mon Feb 25 19:38:13 2002
+++ filemap.c Tue Mar 19 18:20:40 2002
@@ -2885,9 +2885,9 @@
   * Check whether we've reached the file size limit.
   */
  err = -EFBIG;

- if (limit != RLIM_INFINITY) {
+ if (limit != RLIM_INFINITY && !S_ISBLK(inode->i_mode)) {
   if (pos >= limit) {
    send_sig(SIGXFSZ, current, 0);
    goto out;
   }

All this rlimit stuff is a bit wonky in the presence of 64-bit file sizes
anyway. Perhaps if we fix just the block-device case we can brush the rest
under the carpet?

        Peter



  reply	other threads:[~2002-03-19 18:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-19 17:45 setrlimit and RLIM_INFINITY causing fsck failure, 2.4.18 Peter Hartley
2002-03-19 14:15 ` Andreas Dilger
2002-03-19 18:20   ` Peter Hartley [this message]
2002-03-19 18:44     ` Alan Cox
2002-03-20 10:12       ` [PATCH] " Peter Hartley
2002-03-19 18:30   ` Alan Cox
2002-03-19 18:17 ` Alan Cox
2002-03-20  0:10 ` Theodore Tso
2002-03-20  2:04   ` Benjamin LaHaise
2002-03-20 10:09   ` Peter Hartley

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='008301c1cf72$ce5801a0$2701230a@electronic' \
    --to=pdh@utter.chaos.org.uk \
    --cc=adilger@clusterfs.com \
    --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