Merge tag 'for-5.9-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 23 Sep 2020 21:32:23 +0000 (14:32 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 23 Sep 2020 21:32:23 +0000 (14:32 -0700)
Pull btrfs fixes from David Sterba:
 "syzkaller started to hit us with reports, here's a fix for one type
  (stack overflow when printing checksums on read error).

  The other patch is a fix for sysfs object, we have a test for that and
  it leads to a crash."

* tag 'for-5.9-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: fix put of uninitialized kobject after seed device delete
  btrfs: fix overflow when copying corrupt csums for a message

1  2 
fs/btrfs/disk-io.c

diff --combined fs/btrfs/disk-io.c
@@@ -636,16 -636,15 +636,15 @@@ static int btree_readpage_end_io_hook(s
        csum_tree_block(eb, result);
  
        if (memcmp_extent_buffer(eb, result, 0, csum_size)) {
-               u32 val;
-               u32 found = 0;
-               memcpy(&found, result, csum_size);
+               u8 val[BTRFS_CSUM_SIZE] = { 0 };
  
                read_extent_buffer(eb, &val, 0, csum_size);
                btrfs_warn_rl(fs_info,
-               "%s checksum verify failed on %llu wanted %x found %x level %d",
+       "%s checksum verify failed on %llu wanted " CSUM_FMT " found " CSUM_FMT " level %d",
                              fs_info->sb->s_id, eb->start,
-                             val, found, btrfs_header_level(eb));
+                             CSUM_FMT_VALUE(csum_size, val),
+                             CSUM_FMT_VALUE(csum_size, result),
+                             btrfs_header_level(eb));
                ret = -EUCLEAN;
                goto err;
        }
@@@ -1677,6 -1676,27 +1676,6 @@@ struct btrfs_root *btrfs_get_new_fs_roo
        return btrfs_get_root_ref(fs_info, objectid, anon_dev, true);
  }
  
 -static int btrfs_congested_fn(void *congested_data, int bdi_bits)
 -{
 -      struct btrfs_fs_info *info = (struct btrfs_fs_info *)congested_data;
 -      int ret = 0;
 -      struct btrfs_device *device;
 -      struct backing_dev_info *bdi;
 -
 -      rcu_read_lock();
 -      list_for_each_entry_rcu(device, &info->fs_devices->devices, dev_list) {
 -              if (!device->bdev)
 -                      continue;
 -              bdi = device->bdev->bd_bdi;
 -              if (bdi_congested(bdi, bdi_bits)) {
 -                      ret = 1;
 -                      break;
 -              }
 -      }
 -      rcu_read_unlock();
 -      return ret;
 -}
 -
  /*
   * called by the kthread helper functions to finally call the bio end_io
   * functions.  This is where read checksum verification actually happens
@@@ -3091,6 -3111,8 +3090,6 @@@ int __cold open_ctree(struct super_bloc
                goto fail_sb_buffer;
        }
  
 -      sb->s_bdi->congested_fn = btrfs_congested_fn;
 -      sb->s_bdi->congested_data = fs_info;
        sb->s_bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK;
        sb->s_bdi->ra_pages = VM_READAHEAD_PAGES;
        sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super);