]> Git Repo - J-linux.git/commitdiff
Merge tag 'for-5.0-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
authorLinus Torvalds <[email protected]>
Sun, 3 Feb 2019 16:48:33 +0000 (08:48 -0800)
committerLinus Torvalds <[email protected]>
Sun, 3 Feb 2019 16:48:33 +0000 (08:48 -0800)
Pull btrfs fixes from David Sterba:

 - regression fix: transaction commit can run away due to delayed ref
   waiting heuristic, this is not necessary now because of the proper
   reservation mechanism introduced in 5.0

 - regression fix: potential crash due to use-before-check of an ERR_PTR
   return value

 - fix for transaction abort during transaction commit that needs to
   properly clean up pending block groups

 - fix deadlock during b-tree node/leaf splitting, when this happens on
   some of the fundamental trees, we must prevent new tree block
   allocation to re-enter indirectly via the block group flushing path

 - potential memory leak after errors during mount

* tag 'for-5.0-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: On error always free subvol_name in btrfs_mount
  btrfs: clean up pending block groups when transaction commit aborts
  btrfs: fix potential oops in device_list_add
  btrfs: don't end the transaction for delayed refs in throttle
  Btrfs: fix deadlock when allocating tree block during leaf/node split

1  2 
fs/btrfs/super.c

diff --combined fs/btrfs/super.c
index c5586ffd1426fce1c5076f8b18e536affa99600b,74023786a73510ab5d38a6e90185b82e6511dc8b..0a3f122dd61fe1858461c0c760b94b78412f3368
@@@ -1458,6 -1458,56 +1458,6 @@@ out
        return root;
  }
  
 -static int parse_security_options(char *orig_opts,
 -                                struct security_mnt_opts *sec_opts)
 -{
 -      char *secdata = NULL;
 -      int ret = 0;
 -
 -      secdata = alloc_secdata();
 -      if (!secdata)
 -              return -ENOMEM;
 -      ret = security_sb_copy_data(orig_opts, secdata);
 -      if (ret) {
 -              free_secdata(secdata);
 -              return ret;
 -      }
 -      ret = security_sb_parse_opts_str(secdata, sec_opts);
 -      free_secdata(secdata);
 -      return ret;
 -}
 -
 -static int setup_security_options(struct btrfs_fs_info *fs_info,
 -                                struct super_block *sb,
 -                                struct security_mnt_opts *sec_opts)
 -{
 -      int ret = 0;
 -
 -      /*
 -       * Call security_sb_set_mnt_opts() to check whether new sec_opts
 -       * is valid.
 -       */
 -      ret = security_sb_set_mnt_opts(sb, sec_opts, 0, NULL);
 -      if (ret)
 -              return ret;
 -
 -#ifdef CONFIG_SECURITY
 -      if (!fs_info->security_opts.num_mnt_opts) {
 -              /* first time security setup, copy sec_opts to fs_info */
 -              memcpy(&fs_info->security_opts, sec_opts, sizeof(*sec_opts));
 -      } else {
 -              /*
 -               * Since SELinux (the only one supporting security_mnt_opts)
 -               * does NOT support changing context during remount/mount of
 -               * the same sb, this must be the same or part of the same
 -               * security options, just free it.
 -               */
 -              security_free_mnt_opts(sec_opts);
 -      }
 -#endif
 -      return ret;
 -}
 -
  /*
   * Find a superblock for the given device / mount point.
   *
@@@ -1472,15 -1522,16 +1472,15 @@@ static struct dentry *btrfs_mount_root(
        struct btrfs_device *device = NULL;
        struct btrfs_fs_devices *fs_devices = NULL;
        struct btrfs_fs_info *fs_info = NULL;
 -      struct security_mnt_opts new_sec_opts;
 +      void *new_sec_opts = NULL;
        fmode_t mode = FMODE_READ;
        int error = 0;
  
        if (!(flags & SB_RDONLY))
                mode |= FMODE_WRITE;
  
 -      security_init_mnt_opts(&new_sec_opts);
        if (data) {
 -              error = parse_security_options(data, &new_sec_opts);
 +              error = security_sb_eat_lsm_opts(data, &new_sec_opts);
                if (error)
                        return ERR_PTR(error);
        }
  
        fs_info->super_copy = kzalloc(BTRFS_SUPER_INFO_SIZE, GFP_KERNEL);
        fs_info->super_for_commit = kzalloc(BTRFS_SUPER_INFO_SIZE, GFP_KERNEL);
 -      security_init_mnt_opts(&fs_info->security_opts);
        if (!fs_info->super_copy || !fs_info->super_for_commit) {
                error = -ENOMEM;
                goto error_fs_info;
                btrfs_sb(s)->bdev_holder = fs_type;
                error = btrfs_fill_super(s, fs_devices, data);
        }
 +      if (!error)
 +              error = security_sb_set_mnt_opts(s, new_sec_opts, 0, NULL);
 +      security_free_mnt_opts(&new_sec_opts);
        if (error) {
                deactivate_locked_super(s);
 -              goto error_sec_opts;
 -      }
 -
 -      fs_info = btrfs_sb(s);
 -      error = setup_security_options(fs_info, s, &new_sec_opts);
 -      if (error) {
 -              deactivate_locked_super(s);
 -              goto error_sec_opts;
 +              return ERR_PTR(error);
        }
  
        return dget(s->s_root);
@@@ -1621,6 -1677,7 +1621,7 @@@ static struct dentry *btrfs_mount(struc
                                flags | SB_RDONLY, device_name, data);
                        if (IS_ERR(mnt_root)) {
                                root = ERR_CAST(mnt_root);
+                               kfree(subvol_name);
                                goto out;
                        }
  
                        if (error < 0) {
                                root = ERR_PTR(error);
                                mntput(mnt_root);
+                               kfree(subvol_name);
                                goto out;
                        }
                }
        }
        if (IS_ERR(mnt_root)) {
                root = ERR_CAST(mnt_root);
+               kfree(subvol_name);
                goto out;
        }
  
@@@ -1723,14 -1782,18 +1726,14 @@@ static int btrfs_remount(struct super_b
        btrfs_remount_prepare(fs_info);
  
        if (data) {
 -              struct security_mnt_opts new_sec_opts;
 +              void *new_sec_opts = NULL;
  
 -              security_init_mnt_opts(&new_sec_opts);
 -              ret = parse_security_options(data, &new_sec_opts);
 +              ret = security_sb_eat_lsm_opts(data, &new_sec_opts);
 +              if (!ret)
 +                      ret = security_sb_remount(sb, new_sec_opts);
 +              security_free_mnt_opts(&new_sec_opts);
                if (ret)
                        goto restore;
 -              ret = setup_security_options(fs_info, sb,
 -                                           &new_sec_opts);
 -              if (ret) {
 -                      security_free_mnt_opts(&new_sec_opts);
 -                      goto restore;
 -              }
        }
  
        ret = btrfs_parse_options(fs_info, data, *flags);
This page took 0.081793 seconds and 4 git commands to generate.