linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Prevent creation of files larger than RLIMIT_FSIZE using fallocate
@ 2010-04-28 13:24 Nikanth Karthikesan
  2010-04-28 16:15 ` Coly Li
  0 siblings, 1 reply; 19+ messages in thread
From: Nikanth Karthikesan @ 2010-04-28 13:24 UTC (permalink / raw)
  To: Alexander Viro
  Cc: linux-fsdevel, Theodore Ts'o, Andreas Dilger, linux-ext4,
	Andrew Morton, Eelis

Prevent creation of files larger than RLIMIT_FSIZE using fallocate.

Currently using posix_fallocate one can bypass an RLIMIT_FSIZE limit
and create a file larger than the limit. Add a check for new size in
the fallocate system call.

File-systems supporting fallocate such as ext4 are affected by this
bug. 

Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
Reported-by: Eelis - <opensuse.org@contacts.eelis.net>

---

diff --git a/fs/open.c b/fs/open.c
index 74e5cd9..95ce069 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -412,10 +412,14 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
 	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;
 
+	ret = inode_newsize_ok(inode, (offset + len));
+	if (ret)
+		return ret;
+
 	if (!inode->i_op->fallocate)
 		return -EOPNOTSUPP;
 

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-05-21  1:11 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-28 13:24 [PATCH] Prevent creation of files larger than RLIMIT_FSIZE using fallocate Nikanth Karthikesan
2010-04-28 16:15 ` Coly Li
     [not found]   ` <201004291014.07194.knikanth@suse.de>
     [not found]     ` <4BD9239D.6060907@suse.de>
2010-04-29  9:23       ` Andreas Dilger
2010-04-30 21:33     ` Andrew Morton
2010-04-30 21:40       ` Andreas Dilger
2010-05-01  7:04       ` Amit K. Arora
2010-05-01 10:18         ` Christoph Hellwig
2010-05-03  7:01           ` Amit K. Arora
2010-05-03  8:31           ` [PATCH] New testcase to check if fallocate respects RLIMIT_FSIZE or not Amit K. Arora
2010-05-04 20:44             ` Eric Sandeen
2010-05-05  7:55               ` [PATCH v2] " Amit K. Arora
2010-05-05 15:50                 ` Eric Sandeen
2010-05-03  4:23         ` [PATCH] Prevent creation of files larger than RLIMIT_FSIZE using fallocate Nikanth Karthikesan
2010-05-03  6:59           ` Amit K. Arora
2010-05-03  7:49             ` Nikanth Karthikesan
2010-05-04  5:44             ` [PATCH] btrfs: " Nikanth Karthikesan
2010-05-04  5:45             ` [PATCH] ext4: " Nikanth Karthikesan
2010-05-04  6:28               ` Amit K. Arora
2010-05-21  1:11                 ` tytso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).