1. 05 12月, 2021 3 次提交
  2. 02 11月, 2021 3 次提交
  3. 22 10月, 2021 2 次提交
  4. 21 10月, 2021 1 次提交
  5. 18 10月, 2021 1 次提交
  6. 13 10月, 2021 1 次提交
    • J
      dm: fix mempool NULL pointer race when completing IO · d208b894
      Jiazi Li 提交于
      dm_io_dec_pending() calls end_io_acct() first and will then dec md
      in-flight pending count. But if a task is swapping DM table at same
      time this can result in a crash due to mempool->elements being NULL:
      
      task1                             task2
      do_resume
       ->do_suspend
        ->dm_wait_for_completion
                                        bio_endio
      				   ->clone_endio
      				    ->dm_io_dec_pending
      				     ->end_io_acct
      				      ->wakeup task1
       ->dm_swap_table
        ->__bind
         ->__bind_mempools
          ->bioset_exit
           ->mempool_exit
                                           ->free_io
      
      [ 67.330330] Unable to handle kernel NULL pointer dereference at
      virtual address 0000000000000000
      ......
      [ 67.330494] pstate: 80400085 (Nzcv daIf +PAN -UAO)
      [ 67.330510] pc : mempool_free+0x70/0xa0
      [ 67.330515] lr : mempool_free+0x4c/0xa0
      [ 67.330520] sp : ffffff8008013b20
      [ 67.330524] x29: ffffff8008013b20 x28: 0000000000000004
      [ 67.330530] x27: ffffffa8c2ff40a0 x26: 00000000ffff1cc8
      [ 67.330535] x25: 0000000000000000 x24: ffffffdada34c800
      [ 67.330541] x23: 0000000000000000 x22: ffffffdada34c800
      [ 67.330547] x21: 00000000ffff1cc8 x20: ffffffd9a1304d80
      [ 67.330552] x19: ffffffdada34c970 x18: 000000b312625d9c
      [ 67.330558] x17: 00000000002dcfbf x16: 00000000000006dd
      [ 67.330563] x15: 000000000093b41e x14: 0000000000000010
      [ 67.330569] x13: 0000000000007f7a x12: 0000000034155555
      [ 67.330574] x11: 0000000000000001 x10: 0000000000000001
      [ 67.330579] x9 : 0000000000000000 x8 : 0000000000000000
      [ 67.330585] x7 : 0000000000000000 x6 : ffffff80148b5c1a
      [ 67.330590] x5 : ffffff8008013ae0 x4 : 0000000000000001
      [ 67.330596] x3 : ffffff80080139c8 x2 : ffffff801083bab8
      [ 67.330601] x1 : 0000000000000000 x0 : ffffffdada34c970
      [ 67.330609] Call trace:
      [ 67.330616] mempool_free+0x70/0xa0
      [ 67.330627] bio_put+0xf8/0x110
      [ 67.330638] dec_pending+0x13c/0x230
      [ 67.330644] clone_endio+0x90/0x180
      [ 67.330649] bio_endio+0x198/0x1b8
      [ 67.330655] dec_pending+0x190/0x230
      [ 67.330660] clone_endio+0x90/0x180
      [ 67.330665] bio_endio+0x198/0x1b8
      [ 67.330673] blk_update_request+0x214/0x428
      [ 67.330683] scsi_end_request+0x2c/0x300
      [ 67.330688] scsi_io_completion+0xa0/0x710
      [ 67.330695] scsi_finish_command+0xd8/0x110
      [ 67.330700] scsi_softirq_done+0x114/0x148
      [ 67.330708] blk_done_softirq+0x74/0xd0
      [ 67.330716] __do_softirq+0x18c/0x374
      [ 67.330724] irq_exit+0xb4/0xb8
      [ 67.330732] __handle_domain_irq+0x84/0xc0
      [ 67.330737] gic_handle_irq+0x148/0x1b0
      [ 67.330744] el1_irq+0xe8/0x190
      [ 67.330753] lpm_cpuidle_enter+0x4f8/0x538
      [ 67.330759] cpuidle_enter_state+0x1fc/0x398
      [ 67.330764] cpuidle_enter+0x18/0x20
      [ 67.330772] do_idle+0x1b4/0x290
      [ 67.330778] cpu_startup_entry+0x20/0x28
      [ 67.330786] secondary_start_kernel+0x160/0x170
      
      Fix this by:
      1) Establishing pointers to 'struct dm_io' members in
      dm_io_dec_pending() so that they may be passed into end_io_acct()
      _after_ free_io() is called.
      2) Moving end_io_acct() after free_io().
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NJiazi Li <lijiazi@xiaomi.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      d208b894
  7. 27 8月, 2021 1 次提交
  8. 21 8月, 2021 1 次提交
  9. 11 8月, 2021 1 次提交
    • T
      dm ima: measure data on table load · 91ccbbac
      Tushar Sugandhi 提交于
      DM configures a block device with various target specific attributes
      passed to it as a table.  DM loads the table, and calls each target’s
      respective constructors with the attributes as input parameters.
      Some of these attributes are critical to ensure the device meets
      certain security bar.  Thus, IMA should measure these attributes, to
      ensure they are not tampered with, during the lifetime of the device.
      So that the external services can have high confidence in the
      configuration of the block-devices on a given system.
      
      Some devices may have large tables.  And a given device may change its
      state (table-load, suspend, resume, rename, remove, table-clear etc.)
      many times.  Measuring these attributes each time when the device
      changes its state will significantly increase the size of the IMA logs.
      Further, once configured, these attributes are not expected to change
      unless a new table is loaded, or a device is removed and recreated.
      Therefore the clear-text of the attributes should only be measured
      during table load, and the hash of the active/inactive table should be
      measured for the remaining device state changes.
      
      Export IMA function ima_measure_critical_data() to allow measurement
      of DM device parameters, as well as target specific attributes, during
      table load.  Compute the hash of the inactive table and store it for
      measurements during future state change.  If a load is called multiple
      times, update the inactive table hash with the hash of the latest
      populated table.  So that the correct inactive table hash is measured
      when the device transitions to different states like resume, remove,
      rename, etc.
      Signed-off-by: NTushar Sugandhi <tusharsu@linux.microsoft.com>
      Signed-off-by: Colin Ian King <colin.king@canonical.com> # leak fix
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      91ccbbac
  10. 10 8月, 2021 3 次提交
  11. 18 6月, 2021 1 次提交
  12. 05 6月, 2021 5 次提交
    • D
      dm: introduce zone append emulation · bb37d772
      Damien Le Moal 提交于
      For zoned targets that cannot support zone append operations, implement
      an emulation using regular write operations. If the original BIO
      submitted by the user is a zone append operation, change its clone into
      a regular write operation directed at the target zone write pointer
      position.
      
      To do so, an array of write pointer offsets (write pointer position
      relative to the start of a zone) is added to struct mapped_device. All
      operations that modify a sequential zone write pointer (writes, zone
      reset, zone finish and zone append) are intersepted in __map_bio() and
      processed using the new functions dm_zone_map_bio().
      
      Detection of the target ability to natively support zone append
      operations is done from dm_table_set_restrictions() by calling the
      function dm_set_zones_restrictions(). A target that does not support
      zone append operation, either by explicitly declaring it using the new
      struct dm_target field zone_append_not_supported, or because the device
      table contains a non-zoned device, has its mapped device marked with the
      new flag DMF_ZONE_APPEND_EMULATED. The helper function
      dm_emulate_zone_append() is introduced to test a mapped device for this
      new flag.
      
      Atomicity of the zones write pointer tracking and updates is done using
      a zone write locking mechanism based on a bitmap. This is similar to
      the block layer method but based on BIOs rather than struct request.
      A zone write lock is taken in dm_zone_map_bio() for any clone BIO with
      an operation type that changes the BIO target zone write pointer
      position. The zone write lock is released if the clone BIO is failed
      before submission or when dm_zone_endio() is called when the clone BIO
      completes.
      
      The zone write lock bitmap of the mapped device, together with a bitmap
      indicating zone types (conv_zones_bitmap) and the write pointer offset
      array (zwp_offset) are allocated and initialized with a full device zone
      report in dm_set_zones_restrictions() using the function
      dm_revalidate_zones().
      
      For failed operations that may have modified a zone write pointer, the
      zone write pointer offset is marked as invalid in dm_zone_endio().
      Zones with an invalid write pointer offset are checked and the write
      pointer updated using an internal report zone operation when the
      faulty zone is accessed again by the user.
      
      All functions added for this emulation have a minimal overhead for
      zoned targets natively supporting zone append operations. Regular
      device targets are also not affected. The added code also does not
      impact builds with CONFIG_BLK_DEV_ZONED disabled by stubbing out all
      dm zone related functions.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NHimanshu Madhani <himanshu.madhani@oracle.com>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      bb37d772
    • D
      dm: rearrange core declarations for extended use from dm-zone.c · e2118b3c
      Damien Le Moal 提交于
      Move the definitions of struct dm_target_io, struct dm_io and the bits
      of the flags field of struct mapped_device from dm.c to dm-core.h to
      make them usable from dm-zone.c. For the same reason, declare
      dec_pending() in dm-core.h after renaming it to dm_io_dec_pending().
      And for symmetry of the function names, introduce the inline helper
      dm_io_inc_pending() instead of directly using atomic_inc() calls.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Reviewed-by: NHimanshu Madhani <himanshu.madhani@oracle.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      e2118b3c
    • D
      dm: Forbid requeue of writes to zones · bf14e2b2
      Damien Le Moal 提交于
      A target map method requesting the requeue of a bio with
      DM_MAPIO_REQUEUE or completing it with DM_ENDIO_REQUEUE can cause
      unaligned write errors if the bio is a write operation targeting a
      sequential zone. If a zoned target request such a requeue, warn about
      it and kill the IO.
      
      The function dm_is_zone_write() is introduced to detect write operations
      to zoned targets.
      
      This change does not affect the target drivers supporting zoned devices
      and exposing a zoned device, namely dm-crypt, dm-linear and dm-flakey as
      none of these targets ever request a requeue.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Reviewed-by: NHimanshu Madhani <himanshu.madhani@oracle.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      bf14e2b2
    • D
      dm: move zone related code to dm-zone.c · 7fc18728
      Damien Le Moal 提交于
      Move core and table code used for zoned targets and conditionally
      defined with #ifdef CONFIG_BLK_DEV_ZONED to the new file dm-zone.c.
      This file is conditionally compiled depending on CONFIG_BLK_DEV_ZONED.
      The small helper dm_set_zones_restrictions() is introduced to
      initialize a mapped device request queue zone attributes in
      dm_table_set_restrictions().
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Reviewed-by: NHimanshu Madhani <himanshu.madhani@oracle.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      7fc18728
    • D
      dm: Fix dm_accept_partial_bio() relative to zone management commands · 6842d264
      Damien Le Moal 提交于
      Fix dm_accept_partial_bio() to actually check that zone management
      commands are not passed as explained in the function documentation
      comment. Also, since a zone append operation cannot be split, add
      REQ_OP_ZONE_APPEND as a forbidden command.
      
      White lines are added around the group of BUG_ON() calls to make the
      code more legible.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      6842d264
  13. 01 6月, 2021 1 次提交
  14. 27 3月, 2021 2 次提交
  15. 23 3月, 2021 1 次提交
  16. 11 2月, 2021 2 次提交
    • M
      dm: fix deadlock when swapping to encrypted device · a666e5c0
      Mikulas Patocka 提交于
      The system would deadlock when swapping to a dm-crypt device. The reason
      is that for each incoming write bio, dm-crypt allocates memory that holds
      encrypted data. These excessive allocations exhaust all the memory and the
      result is either deadlock or OOM trigger.
      
      This patch limits the number of in-flight swap bios, so that the memory
      consumed by dm-crypt is limited. The limit is enforced if the target set
      the "limit_swap_bios" variable and if the bio has REQ_SWAP set.
      
      Non-swap bios are not affected becuase taking the semaphore would cause
      performance degradation.
      
      This is similar to request-based drivers - they will also block when the
      number of requests is over the limit.
      Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      a666e5c0
    • S
      dm: add support for passing through inline crypto support · aa6ce87a
      Satya Tangirala 提交于
      Update the device-mapper core to support exposing the inline crypto
      support of the underlying device(s) through the device-mapper device.
      
      This works by creating a "passthrough keyslot manager" for the dm
      device, which declares support for encryption settings which all
      underlying devices support.  When a supported setting is used, the bio
      cloning code handles cloning the crypto context to the bios for all the
      underlying devices.  When an unsupported setting is used, the blk-crypto
      fallback is used as usual.
      
      Crypto support on each underlying device is ignored unless the
      corresponding dm target opts into exposing it.  This is needed because
      for inline crypto to semantically operate on the original bio, the data
      must not be transformed by the dm target.  Thus, targets like dm-linear
      can expose crypto support of the underlying device, but targets like
      dm-crypt can't.  (dm-crypt could use inline crypto itself, though.)
      
      A DM device's table can only be changed if the "new" inline encryption
      capabilities are a (*not* necessarily strict) superset of the "old" inline
      encryption capabilities.  Attempts to make changes to the table that result
      in some inline encryption capability becoming no longer supported will be
      rejected.
      
      For the sake of clarity, key eviction from underlying devices will be
      handled in a future patch.
      Co-developed-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NSatya Tangirala <satyat@google.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      aa6ce87a
  17. 09 2月, 2021 1 次提交
  18. 03 2月, 2021 1 次提交
  19. 25 1月, 2021 1 次提交
  20. 09 1月, 2021 1 次提交
  21. 05 12月, 2020 6 次提交
  22. 02 12月, 2020 1 次提交