diff options
author | Eric Sandeen <sandeen@redhat.com> | 2008-01-28 23:58:27 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-01-28 23:58:27 -0500 |
commit | e2b4657453c0d5571bd3c7256585c486ed42d364 (patch) | |
tree | 5b8ab501cdf5fa7427ef32440ace56eac72e9ecf /fs/ext4/inode.c | |
parent | 19295529db35381d46dbaf246f69b4e3b3393996 (diff) |
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>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 9cf85721d83c..eaace1373ccb 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -314,7 +314,10 @@ static int ext4_block_to_path(struct inode *inode, | |||
314 | offsets[n++] = i_block & (ptrs - 1); | 314 | offsets[n++] = i_block & (ptrs - 1); |
315 | final = ptrs; | 315 | final = ptrs; |
316 | } else { | 316 | } else { |
317 | ext4_warning(inode->i_sb, "ext4_block_to_path", "block > big"); | 317 | ext4_warning(inode->i_sb, "ext4_block_to_path", |
318 | "block %u > max", | ||
319 | i_block + direct_blocks + | ||
320 | indirect_blocks + double_blocks); | ||
318 | } | 321 | } |
319 | if (boundary) | 322 | if (boundary) |
320 | *boundary = final - 1 - (i_block & (ptrs - 1)); | 323 | *boundary = final - 1 - (i_block & (ptrs - 1)); |
@@ -3092,6 +3095,17 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) | |||
3092 | ext4_journal_stop(handle); | 3095 | ext4_journal_stop(handle); |
3093 | } | 3096 | } |
3094 | 3097 | ||
3098 | if (attr->ia_valid & ATTR_SIZE) { | ||
3099 | if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) { | ||
3100 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | ||
3101 | |||
3102 | if (attr->ia_size > sbi->s_bitmap_maxbytes) { | ||
3103 | error = -EFBIG; | ||
3104 | goto err_out; | ||
3105 | } | ||
3106 | } | ||
3107 | } | ||
3108 | |||
3095 | if (S_ISREG(inode->i_mode) && | 3109 | if (S_ISREG(inode->i_mode) && |
3096 | attr->ia_valid & ATTR_SIZE && attr->ia_size < inode->i_size) { | 3110 | attr->ia_valid & ATTR_SIZE && attr->ia_size < inode->i_size) { |
3097 | handle_t *handle; | 3111 | handle_t *handle; |