Re: negative seek offsets in VFS
[Posted May 31, 2005 by corbet]
| From: |
| Linus Torvalds <torvalds-AT-osdl.org> |
| To: |
| Al Viro <viro-AT-parcelfarce.linux.theplanet.co.uk> |
| Subject: |
| Re: negative seek offsets in VFS |
| Date: |
| Thu, 26 May 2005 08:29:40 -0700 (PDT) |
| Cc: |
| Andi Kleen <ak-AT-muc.de>, viro-AT-www.linux.org.uk,
linux-fsdevel-AT-vger.kernel.org |
| Archive-link: |
| Article,
Thread
|
On Thu, 26 May 2005, Al Viro wrote:
>
> How about
> if (unlikely((pos < 0) || (loff_t) (pos + count) < 0))
> if (!(file->f_mode & FMODE_ANY_OFFSET))
> goto Einval;
>
> instead + adding
> #define FMODE_ANY_OFFSET 16 /* we don't need any offset checks */
> in fs.h + having kmem ->open() set it?
>
> Linus, it's your code. Do you have any objections to the above?
No. But if so, the test should be changed: right now it not only detects
negative offsets, it also detects wrap-around. And I think that
wrap-around is _always_ wrong.
I don't think there is a "positive loff_t", so I guess the code would have
to be something like
/* Wraparound? */
if ((u64)(pos + count) < count)
goto Einval;
if ((loff_t) (pos + count) < 0)
if (!(file->f_mode & FMODE_ANY_OFFSET))
goto Einval;
instead.
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
(
Log in to post comments)