summaryrefslogtreecommitdiffstats
path: root/fs/ext4/file.c
diff options
context:
space:
mode:
authorToshiyuki Okajima <toshi.okajima@jp.fujitsu.com>2010-07-27 11:56:07 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-07-27 11:56:07 -0400
commitd889dc8382c4d71b6d538b7b13777bc1ec51df10 (patch)
treee789637cb83e053a5d9706d4a66d20411cec2261 /fs/ext4/file.c
parent79e8303677fc15f508b9877e0fea1925c4add6f3 (diff)
downloadop-kernel-dev-d889dc8382c4d71b6d538b7b13777bc1ec51df10.zip
op-kernel-dev-d889dc8382c4d71b6d538b7b13777bc1ec51df10.tar.gz
ext4: fix EFBIG edge case when writing to large non-extent file
By running the following reproducer, we can confirm that the write system call returns with 0 when it should return the error EFBIG. #!/bin/sh /bin/dd if=/dev/zero of=./img bs=1k count=1 seek=1024k > /dev/null 2>&1 /sbin/mkfs.ext3 -Fq ./img /bin/mount -o loop -t ext4 ./img /mnt /bin/touch /mnt/file strace /bin/dd if=/dev/zero of=/mnt/file conv=notrunc bs=1k count=1 seek=$((2194719883264/1024)) 2>&1 | /bin/egrep "write.* 1024\) = " /bin/umount /mnt exit Signed-off-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: Eric Sandeen <sandeen@redhat.com>
Diffstat (limited to 'fs/ext4/file.c')
-rw-r--r--fs/ext4/file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index bd411c1..ee92b66 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -70,7 +70,8 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
size_t length = iov_length(iov, nr_segs);
- if (pos > sbi->s_bitmap_maxbytes)
+ if ((pos > sbi->s_bitmap_maxbytes ||
+ (pos == sbi->s_bitmap_maxbytes && length > 0)))
return -EFBIG;
if (pos + length > sbi->s_bitmap_maxbytes) {
OpenPOWER on IntegriCloud