From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: Andreas Dilger <adilger@turbolabs.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: generic_file_llseek() broken?
Date: 15 Nov 2001 10:55:07 +0100 [thread overview]
Message-ID: <shsd72kcq9w.fsf@charged.uio.no> (raw)
In-Reply-To: <UTC200111150055.AAA93544.aeb@cwi.nl> <20011115020259.C5739@lynx.no>
In-Reply-To: <20011115020259.C5739@lynx.no>
>>>>> " " == Andreas Dilger <adilger@turbolabs.com> writes:
> --- linux.orig/fs/read_write.c Tue Aug 14 12:09:09 2001
> +++ linux/fs/read_write.c Thu Nov 15 01:54:35 2001
> @@ -36,15 +36,24 @@
> case 1:
> offset += file->f_pos;
> }
> +
> + /* LFS 2.1.1.6: can't seek to a position that doesn't fit in
> off_t */
> + retval = -EOVERFLOW;
> + if ((!(file->f_flags & O_LARGEFILE) && offset > MAX_NON_LFS)
> ||
> + offset > file->f_dentry->d_inode->i_sb->s_maxbytes)
> + goto out;
> +
> retval = -EINVAL;
> - if (offset>=0 &&
> offset<=file->f_dentry->d_inode->i_sb->s_maxbytes) {
> - if (offset != file->f_pos) {
> - file->f_pos = offset;
> - file->f_reada = 0;
> - file->f_version = ++event;
> - }
> - retval = offset;
> + if (offset < 0)
> + goto out;
> +
> + if (offset != file->f_pos) {
> + file->f_pos = offset;
> + file->f_reada = 0;
> + file->f_version = ++event;
> }
> + retval = offset;
> +out:
> return retval;
> }
> @@ -64,6 +73,12 @@
> case 1:
> offset += file->f_pos;
> }
> +
> + /* LFS 2.1.1.6: can't seek to a position that doesn't fit in
> off_t */
> + retval = -EOVERFLOW;
> + if (!(file->f_flags & O_LARGEFILE) && offset > MAX_NON_LFS)
> + goto out;
> +
> retval = -EINVAL; if (offset >= 0) {
> if (offset != file->f_pos) {
> @@ -73,6 +88,7 @@
> } retval = offset;
> }
> +out:
> return retval;
> }
> @@ -103,8 +119,6 @@
> if (origin <= 2) {
> loff_t res = llseek(file, offset, origin);
> retval = res;
> - if (res != (loff_t)retval)
> - retval = -EOVERFLOW; /* LFS: should only happen on 32 bit
> platforms */
> } fput(file);
> bad:
This breaks NFS badly for which a directory seek position is *not* a
file offset, but is an unsigned cookie. Please ensure that the above
checks are only made on regular files.
Cheers,
Trond
next prev parent reply other threads:[~2001-11-15 9:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-15 0:55 generic_file_llseek() broken? Andries.Brouwer
2001-11-15 9:02 ` Andreas Dilger
2001-11-15 9:55 ` Trond Myklebust [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-11-14 23:51 Andreas Dilger
2001-11-15 0:08 ` Alan Cox
2001-11-15 0:46 ` Andreas Dilger
2001-11-15 1:47 ` David Gomez
2001-11-15 5:24 ` Andreas Dilger
[not found] ` <3BF38CFB.21998301@idb.hist.no>
2001-11-15 21:09 ` Andreas Dilger
2001-11-15 22:02 ` Alan Cox
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=shsd72kcq9w.fsf@charged.uio.no \
--to=trond.myklebust@fys.uio.no \
--cc=adilger@turbolabs.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