aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inline.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2014-01-07 12:58:19 -0500
committerTheodore Ts'o <tytso@mit.edu>2014-01-07 12:58:19 -0500
commit09c455aaa8f47a94d5bafaa23d58365768210507 (patch)
tree7fb44f2b231481487f6076d10f09939167a95bc2 /fs/ext4/inline.c
parent65eddb56f465f314502679ceade6fc5848a53a50 (diff)
ext4: avoid clearing beyond i_blocks when truncating an inline data file
A missing cast means that when we are truncating a file which is less than 60 bytes, we don't clear the correct area of memory, and in fact we can end up truncating the next inode in the inode table, or worse yet, some other kernel data structure. Addresses-Coverity-Id: #751987 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/ext4/inline.c')
-rw-r--r--fs/ext4/inline.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index c417e52d194e..ed29e720e880 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1928,9 +1928,11 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
1928 } 1928 }
1929 1929
1930 /* Clear the content within i_blocks. */ 1930 /* Clear the content within i_blocks. */
1931 if (i_size < EXT4_MIN_INLINE_DATA_SIZE) 1931 if (i_size < EXT4_MIN_INLINE_DATA_SIZE) {
1932 memset(ext4_raw_inode(&is.iloc)->i_block + i_size, 0, 1932 void *p = (void *) ext4_raw_inode(&is.iloc)->i_block;
1933 EXT4_MIN_INLINE_DATA_SIZE - i_size); 1933 memset(p + i_size, 0,
1934 EXT4_MIN_INLINE_DATA_SIZE - i_size);
1935 }
1934 1936
1935 EXT4_I(inode)->i_inline_size = i_size < 1937 EXT4_I(inode)->i_inline_size = i_size <
1936 EXT4_MIN_INLINE_DATA_SIZE ? 1938 EXT4_MIN_INLINE_DATA_SIZE ?