ext4: store maxbytes for bitmapped files and return EFBIG as appropriate
Calculate & store the max offset for bitmapped files, and catch too-large seeks, truncates, and writes in ext4, shortening or rejecting as appropriate. Signed-off-by: Eric Sandeen <sandeen@redhat.com>
This commit is contained in:
committed by
Theodore Ts'o
parent
19295529db
commit
e2b4657453
@@ -314,7 +314,10 @@ static int ext4_block_to_path(struct inode *inode,
|
||||
offsets[n++] = i_block & (ptrs - 1);
|
||||
final = ptrs;
|
||||
} else {
|
||||
ext4_warning(inode->i_sb, "ext4_block_to_path", "block > big");
|
||||
ext4_warning(inode->i_sb, "ext4_block_to_path",
|
||||
"block %u > max",
|
||||
i_block + direct_blocks +
|
||||
indirect_blocks + double_blocks);
|
||||
}
|
||||
if (boundary)
|
||||
*boundary = final - 1 - (i_block & (ptrs - 1));
|
||||
@@ -3092,6 +3095,17 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
|
||||
ext4_journal_stop(handle);
|
||||
}
|
||||
|
||||
if (attr->ia_valid & ATTR_SIZE) {
|
||||
if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) {
|
||||
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
|
||||
|
||||
if (attr->ia_size > sbi->s_bitmap_maxbytes) {
|
||||
error = -EFBIG;
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (S_ISREG(inode->i_mode) &&
|
||||
attr->ia_valid & ATTR_SIZE && attr->ia_size < inode->i_size) {
|
||||
handle_t *handle;
|
||||
|
Reference in New Issue
Block a user