ext2: Fix possible sleep in atomic during mount option parsing
authorJan Kara <jack@suse.cz>
Mon, 9 Oct 2017 14:46:40 +0000 (16:46 +0200)
committerJan Kara <jack@suse.cz>
Wed, 11 Oct 2017 09:43:24 +0000 (11:43 +0200)
match_int() used in mount option parsing can allocate memory using
GFP_KERNEL and thus sleep. Avoid parsing mount options with sbi->s_lock
held.

Signed-off-by: Jan Kara <jack@suse.cz>
fs/ext2/super.c

index 05eae20d133f2f72ec0c02a8ac8a6ec426c14490..e2b6be03e69b5aee2987c13bdfac9055e66d9064 100644 (file)
@@ -1321,20 +1321,20 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
        int err;
 
        sync_filesystem(sb);
-       spin_lock(&sbi->s_lock);
 
+       spin_lock(&sbi->s_lock);
        new_opts.s_mount_opt = sbi->s_mount_opt;
        new_opts.s_resuid = sbi->s_resuid;
        new_opts.s_resgid = sbi->s_resgid;
+       spin_unlock(&sbi->s_lock);
 
        /*
         * Allow the "check" option to be passed as a remount option.
         */
-       if (!parse_options(data, sb, &new_opts)) {
-               spin_unlock(&sbi->s_lock);
+       if (!parse_options(data, sb, &new_opts))
                return -EINVAL;
-       }
 
+       spin_lock(&sbi->s_lock);
        es = sbi->s_es;
        if ((sbi->s_mount_opt ^ new_opts.s_mount_opt) & EXT2_MOUNT_DAX) {
                ext2_msg(sb, KERN_WARNING, "warning: refusing change of "