Patch "ext4: fix in-superblock mount options processing" has been added to the 4.8-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
ext4: fix in-superblock mount options processing
to the 4.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
ext4-fix-in-superblock-mount-options-processing.patch
and it can be found in the queue-4.8 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
5aee0f8a3f42c94c5012f1673420aee96315925aMon Sep 17 00:00:00 2001
From: Theodore Ts'o <[email protected]>
Date: Fri, 18 Nov 2016 13:24:26 -0500
Subject: ext4: fix in-superblock mount options processing
From: Theodore Ts'o <[email protected]>
commit 5aee0f8a3f42c94c5012f1673420aee96315925a upstream.
Fix a large number of problems with how we handle mount options in the superblock. For one, if the string in the superblock is long enough that it is not null terminated, we could run off the end of the string and try to interpret superblocks fields as characters. It's unlikely this will cause a security problem, but it could result in an invalid parse. Also, parse_options is destructive to the string, so in some cases if there is a comma-separated string, it would be modified in the superblock. (Fortunately it only happens on file systems with a 1k block size.)
--- fs/ext4/super.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-)
fs/ext4/super.c +23 -15
@@ -3254,7 +3254,7 @@ static int ext4_fill_super(struct super_char *orig_data =kstrdup (data,GFP_KERNEL );struct buffer_head *bh;struct ext4_super_block *es =NULL ; -struct ext4_sb_info *sbi; +struct ext4_sb_info *sbi =kzalloc (sizeof (*sbi),GFP_KERNEL );ext4_fsblk_t block;ext4_fsblk_t sb_block =get_sb_block (&data);ext4_fsblk_t logical_sb_block;
@@ -3273,16 +3273,14 @@ static int ext4_fill_super(struct super_unsigned int journal_ioprio =DEFAULT_JOURNAL_IOPRIO ;ext4_group_t first_not_zeroed; - sbi =kzalloc (sizeof (*sbi),GFP_KERNEL ); -if (!sbi) - goto out_free_orig; +if ((data && !orig_data) || !sbi) + goto out_free_base; sbi->s_blockgroup_lock =kzalloc (sizeof (struct blockgroup_lock ),GFP_KERNEL ); -if (!sbi->s_blockgroup_lock) { -kfree (sbi); - goto out_free_orig; - } +if (!sbi->s_blockgroup_lock) + goto out_free_base; + sb->s_fs_info = sbi; sbi->s_sb = sb; sbi->s_inode_readahead_blks =EXT4_DEF_INODE_READAHEAD_BLKS ;
@@ -3428,11 +3426,19 @@ static int ext4_fill_super(struct super_*/ sbi->s_li_wait_mult =EXT4_DEF_LI_WAIT_MULT ; -if (!parse_options ((char *) sbi->s_es->s_mount_opts, sb, - &journal_devnum, &journal_ioprio,0 )) { -ext4_msg (sb,KERN_WARNING , -"failed to parse options in superblock: %s" , - sbi->s_es->s_mount_opts); +if (sbi->s_es->s_mount_opts[0 ]) { +char *s_mount_opts =kstrndup (sbi->s_es->s_mount_opts, +sizeof (sbi->s_es->s_mount_opts), +GFP_KERNEL ); +if (!s_mount_opts) + goto failed_mount; +if (!parse_options (s_mount_opts, sb, &journal_devnum, + &journal_ioprio,0 )) { +ext4_msg (sb,KERN_WARNING , +"failed to parse options in superblock: %s" , + s_mount_opts); + } +kfree (s_mount_opts); } sbi->s_def_mount_opt = sbi->s_mount_opt; if (!parse_options((char *) data, sb, &journal_devnum,
@@ -4110,7 +4116,9 @@ no_journal:if (___ratelimit (&ext4_mount_msg_ratelimit,"EXT4-fs mount" ))ext4_msg (sb,KERN_INFO ,"mounted filesystem with%s. " -"Opts: %s%s%s" , descr, sbi->s_es->s_mount_opts, +"Opts: %.*s%s%s" , descr, + (int )sizeof (sbi->s_es->s_mount_opts), + sbi->s_es->s_mount_opts, *sbi->s_es->s_mount_opts ?"; " :"" , orig_data);if (es->s_error_count)
@@ -4189,8 +4197,8 @@ failed_mount: out_fail: sb->s_fs_info =NULL ;kfree (sbi->s_blockgroup_lock); +out_free_base:kfree (sbi); -out_free_orig:kfree (orig_data);return err ? err : ret; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.8/ext4-reject-inodes-with-negative-size.patch queue-4.8/ext4-fix-in-superblock-mount-options-processing.patch queue-4.8/ext4-fix-mballoc-breakage-with-64k-block-size.patch queue-4.8/ext4-do-not-perform-data-journaling-when-data-is-encrypted.patch queue-4.8/ext4-use-more-strict-checks-for-inodes_per_block-on-mount.patch queue-4.8/ext4-add-sanity-checking-to-count_overhead.patch queue-4.8/ext4-return-enomem-instead-of-success.patch queue-4.8/ext4-fix-stack-memory-corruption-with-64k-block-size.patch