mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-12 03:26:26 +00:00
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>
This commit is contained in:
parent
79e8303677
commit
d889dc8382
1 changed files with 2 additions and 1 deletions
|
@ -70,7 +70,8 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
|
||||||
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
|
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
|
||||||
size_t length = iov_length(iov, nr_segs);
|
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;
|
return -EFBIG;
|
||||||
|
|
||||||
if (pos + length > sbi->s_bitmap_maxbytes) {
|
if (pos + length > sbi->s_bitmap_maxbytes) {
|
||||||
|
|
Loading…
Reference in a new issue