1. 22 Feb, 2022 5 commits
    • Kirill Tkhai's avatar
      dm: fix use-after-free in dm_cleanup_zoned_dev() · 588b7f5d
      Kirill Tkhai authored
      dm_cleanup_zoned_dev() uses queue, so it must be called
      before blk_cleanup_disk() starts its killing:
      
      blk_cleanup_disk->blk_cleanup_queue()->kobject_put()->blk_release_queue()->
      ->...RCU...->blk_free_queue_rcu()->kmem_cache_free()
      
      Otherwise, RCU callback may be executed first and
      dm_cleanup_zoned_dev() will touch free'd memory:
      
       BUG: KASAN: use-after-free in dm_cleanup_zoned_dev+0x33/0xd0
       Read of size 8 at addr ffff88805ac6e430 by task dmsetup/681
      
       CPU: 4 PID: 681 Comm: dmsetup Not tainted 5.17.0-rc2+ #6
       Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
       Call Trace:
        <TASK>
        dump_stack_lvl+0x57/0x7d
        print_address_description.constprop.0+0x1f/0x150
        ? dm_cleanup_zoned_dev+0x33/0xd0
        kasan_report.cold+0x7f/0x11b
        ? dm_cleanup_zoned_dev+0x33/0xd0
        dm_cleanup_zoned_dev+0x33/0xd0
        __dm_destroy+0x26a/0x400
        ? dm_blk_ioctl+0x230/0x230
        ? up_write+0xd8/0x270
        dev_remove+0x156/0x1d0
        ctl_ioctl+0x269/0x530
        ? table_clear+0x140/0x140
        ? lock_release+0xb2/0x750
        ? remove_all+0x40/0x40
        ? rcu_read_lock_sched_held+0x12/0x70
        ? lock_downgrade+0x3c0/0x3c0
        ? rcu_read_lock_sched_held+0x12/0x70
        dm_ctl_ioctl+0xa/0x10
        __x64_sys_ioctl+0xb9/0xf0
        do_syscall_64+0x3b/0x90
        entry_SYSCALL_64_after_hwframe+0x44/0xae
       RIP: 0033:0x7fb6dfa95c27
      
      Fixes: bb37d772 ("dm: introduce zone append emulation")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Reviewed-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      588b7f5d
    • Jordy Zomer's avatar
      dm ioctl: prevent potential spectre v1 gadget · cd9c88da
      Jordy Zomer authored
      It appears like cmd could be a Spectre v1 gadget as it's supplied by a
      user and used as an array index. Prevent the contents of kernel memory
      from being leaked to userspace via speculative execution by using
      array_index_nospec.
      Signed-off-by: default avatarJordy Zomer <jordy@pwning.systems>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      cd9c88da
    • Tom Rix's avatar
      dm: cleanup double word in comment · a8b9d116
      Tom Rix authored
      Remove the second 'a'.
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      a8b9d116
    • Thore Sommer's avatar
      dm ima: fix wrong length calculation for no_data string · 118f31b4
      Thore Sommer authored
      All entries measured by dm ima are prefixed by a version string
      (dm_version=N.N.N). When there is no data to measure, the entire buffer is
      overwritten with a string containing the version string again and the
      length of that string is added to the length of the version string.
      The new length is now wrong because it contains the version string twice.
      
      This caused entries like this:
      dm_version=4.45.0;name=test,uuid=test;table_clear=no_data; \
      \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \
      current_device_capacity=204808;
      Signed-off-by: default avatarThore Sommer <public@thson.de>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      118f31b4
    • Colin Ian King's avatar
      dm cache policy smq: make static read-only array table const · 302f0351
      Colin Ian King authored
      The 'table' static array is read-only so it make sense to make
      it const. Add in the int type to clean up checkpatch warning.
      Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      302f0351
  2. 21 Feb, 2022 19 commits
  3. 17 Feb, 2022 16 commits