[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <C968C336-E9B4-41A1-96DE-E264827F936E@oracle.com>
Date: Fri, 30 Apr 2010 15:40:14 -0600
From: Andreas Dilger <andreas.dilger@...cle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Nikanth Karthikesan <knikanth@...e.de>, coly.li@...e.de,
Nick Piggin <npiggin@...e.de>,
Alexander Viro <viro@...iv.linux.org.uk>,
linux-fsdevel@...r.kernel.org, "Theodore Ts'o" <tytso@....edu>,
linux-ext4@...r.kernel.org,
Eelis <opensuse.org@...tacts.eelis.net>,
Amit Arora <aarora@...ibm.com>
Subject: Re: [PATCH] Prevent creation of files larger than RLIMIT_FSIZE using fallocate
On 2010-04-30, at 15:33, Andrew Morton wrote:
> On Thu, 29 Apr 2010 10:14:06 +0530
> Nikanth Karthikesan <knikanth@...e.de> wrote:
>> diff --git a/fs/open.c b/fs/open.c
>> index 74e5cd9..4ca57c9 100644
>> --- a/fs/open.c
>> +++ b/fs/open.c
>> @@ -405,17 +405,26 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
>> if (S_ISFIFO(inode->i_mode))
>> return -ESPIPE;
>>
>> - /*
>> - * Let individual file system decide if it supports preallocation
>> - * for directories or not.
>> - */
>> - if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
>> - return -ENODEV;
>> -
>> - /* Check for wrap through zero too */
>> - if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0))
>> + /* Check for wrap through zero */
>> + if (offset+len < 0)
>> return -EFBIG;
>
> I suggest that this test be moved up to where the function tests `if
> (offset < 0 || len <= 0)' - it seems more logical.
Sometimes the order of these checks is mandated by POSIX because of the error return code. I'm not saying for sure that is the case here, but sometimes logic doesn't come into the specification. :-/
Cheers, Andreas
--
Andreas Dilger
Lustre Technical Lead
Oracle Corporation Canada Inc.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists