diff mbox

ext4: mark inode dirty after converting inline directory

Message ID 20170222212246.60931-1-ebiggers3@gmail.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Eric Biggers Feb. 22, 2017, 9:22 p.m. UTC
From: Eric Biggers <ebiggers@google.com>

If ext4_convert_inline_data() was called on a directory with inline
data, the filesystem was left in an inconsistent state (as considered by
e2fsck) because the file size was not increased to cover the new block.
This happened because the inode was not marked dirty after i_disksize
was updated.  Fix this by marking the inode dirty at the end of
ext4_finish_convert_inline_dir().

This bug was probably not noticed before because most users mark the
inode dirty afterwards for other reasons.  But if userspace executed
FS_IOC_SET_ENCRYPTION_POLICY with invalid parameters, as exercised by
'kvm-xfstests -c adv generic/396', then the inode was never marked dirty
after updating i_disksize.

Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/ext4/inline.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Theodore Ts'o March 15, 2017, 6:41 p.m. UTC | #1
On Wed, Feb 22, 2017 at 01:22:46PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> If ext4_convert_inline_data() was called on a directory with inline
> data, the filesystem was left in an inconsistent state (as considered by
> e2fsck) because the file size was not increased to cover the new block.
> This happened because the inode was not marked dirty after i_disksize
> was updated.  Fix this by marking the inode dirty at the end of
> ext4_finish_convert_inline_dir().
> 
> This bug was probably not noticed before because most users mark the
> inode dirty afterwards for other reasons.  But if userspace executed
> FS_IOC_SET_ENCRYPTION_POLICY with invalid parameters, as exercised by
> 'kvm-xfstests -c adv generic/396', then the inode was never marked dirty
> after updating i_disksize.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Applied, thanks.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-fscrypt" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o March 15, 2017, 6:53 p.m. UTC | #2
On Wed, Feb 22, 2017 at 01:22:46PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> If ext4_convert_inline_data() was called on a directory with inline
> data, the filesystem was left in an inconsistent state (as considered by
> e2fsck) because the file size was not increased to cover the new block.
> This happened because the inode was not marked dirty after i_disksize
> was updated.  Fix this by marking the inode dirty at the end of
> ext4_finish_convert_inline_dir().
> 
> This bug was probably not noticed before because most users mark the
> inode dirty afterwards for other reasons.  But if userspace executed
> FS_IOC_SET_ENCRYPTION_POLICY with invalid parameters, as exercised by
> 'kvm-xfstests -c adv generic/396', then the inode was never marked dirty
> after updating i_disksize.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Thanks, applied.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-fscrypt" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 3a1f2822541b..75b29c25313c 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1169,10 +1169,9 @@  static int ext4_finish_convert_inline_dir(handle_t *handle,
 	set_buffer_uptodate(dir_block);
 	err = ext4_handle_dirty_dirent_node(handle, inode, dir_block);
 	if (err)
-		goto out;
+		return err;
 	set_buffer_verified(dir_block);
-out:
-	return err;
+	return ext4_mark_inode_dirty(handle, inode);
 }
 
 static int ext4_convert_inline_data_nolock(handle_t *handle,