1. 21 8月, 2021 1 次提交
    • T
      dm ima: update dm target attributes for ima measurements · 33ace4ca
      Tushar Sugandhi 提交于
      Certain DM targets ('integrity', 'multipath', 'verity') need to update the
      way their attributes are recorded in the ima log, so that the attestation
      servers can interpret the data correctly and decide if the devices
      meet the attestation requirements.  For instance, the "mode=%c" attribute
      in the 'integrity' target is measured twice, the 'verity' target is
      missing the attribute "root_hash_sig_key_desc=%s", and the 'multipath'
      target needs to index the attributes properly.
      
      Update 'integrity' target to remove the duplicate measurement of
      the attribute "mode=%c".  Add "root_hash_sig_key_desc=%s" attribute
      for the 'verity' target.  Index various attributes in 'multipath'
      target.  Also, add "nr_priority_groups=%u" attribute to 'multipath'
      target to record the number of priority groups.
      Signed-off-by: NTushar Sugandhi <tusharsu@linux.microsoft.com>
      Suggested-by: NThore Sommer <public@thson.de>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      33ace4ca
  2. 17 8月, 2021 1 次提交
  3. 11 8月, 2021 1 次提交
    • T
      dm: update target status functions to support IMA measurement · 8ec45662
      Tushar Sugandhi 提交于
      For device mapper targets to take advantage of IMA's measurement
      capabilities, the status functions for the individual targets need to be
      updated to handle the status_type_t case for value STATUSTYPE_IMA.
      
      Update status functions for the following target types, to log their
      respective attributes to be measured using IMA.
       01. cache
       02. crypt
       03. integrity
       04. linear
       05. mirror
       06. multipath
       07. raid
       08. snapshot
       09. striped
       10. verity
      
      For rest of the targets, handle the STATUSTYPE_IMA case by setting the
      measurement buffer to NULL.
      
      For IMA to measure the data on a given system, the IMA policy on the
      system needs to be updated to have the following line, and the system
      needs to be restarted for the measurements to take effect.
      
      /etc/ima/ima-policy
       measure func=CRITICAL_DATA label=device-mapper template=ima-buf
      
      The measurements will be reflected in the IMA logs, which are located at:
      
      /sys/kernel/security/integrity/ima/ascii_runtime_measurements
      /sys/kernel/security/integrity/ima/binary_runtime_measurements
      
      These IMA logs can later be consumed by various attestation clients
      running on the system, and send them to external services for attesting
      the system.
      
      The DM target data measured by IMA subsystem can alternatively
      be queried from userspace by setting DM_IMA_MEASUREMENT_FLAG with
      DM_TABLE_STATUS_CMD.
      Signed-off-by: NTushar Sugandhi <tusharsu@linux.microsoft.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      8ec45662
  4. 14 5月, 2021 2 次提交
  5. 01 5月, 2021 3 次提交
  6. 20 4月, 2021 1 次提交
  7. 27 3月, 2021 1 次提交
    • M
      dm integrity: add the "reset_recalculate" feature flag · db7b93e3
      Mikulas Patocka 提交于
      Add a new flag "reset_recalculate" that will restart recalculating
      from the beginning of the device. It can be used if we want to change
      the hash function. Example:
      
      dmsetup remove_all
      rmmod brd
      set -e
      modprobe brd rd_size=1048576
      dmsetup create in --table '0 2000000 integrity /dev/ram0 0 16 J 2 internal_hash:sha256 recalculate'
      sleep 10
      dmsetup status
      dmsetup remove in
      dmsetup create in --table '0 2000000 integrity /dev/ram0 0 16 J 2 internal_hash:sha3-256 reset_recalculate'
      Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      db7b93e3
  8. 03 2月, 2021 2 次提交
  9. 22 1月, 2021 2 次提交
  10. 13 1月, 2021 1 次提交
  11. 09 1月, 2021 1 次提交
  12. 17 11月, 2020 1 次提交
  13. 02 9月, 2020 1 次提交
  14. 08 8月, 2020 1 次提交
    • W
      mm, treewide: rename kzfree() to kfree_sensitive() · 453431a5
      Waiman Long 提交于
      As said by Linus:
      
        A symmetric naming is only helpful if it implies symmetries in use.
        Otherwise it's actively misleading.
      
        In "kzalloc()", the z is meaningful and an important part of what the
        caller wants.
      
        In "kzfree()", the z is actively detrimental, because maybe in the
        future we really _might_ want to use that "memfill(0xdeadbeef)" or
        something. The "zero" part of the interface isn't even _relevant_.
      
      The main reason that kzfree() exists is to clear sensitive information
      that should not be leaked to other future users of the same memory
      objects.
      
      Rename kzfree() to kfree_sensitive() to follow the example of the recently
      added kvfree_sensitive() and make the intention of the API more explicit.
      In addition, memzero_explicit() is used to clear the memory to make sure
      that it won't get optimized away by the compiler.
      
      The renaming is done by using the command sequence:
      
        git grep -w --name-only kzfree |\
        xargs sed -i 's/kzfree/kfree_sensitive/'
      
      followed by some editing of the kfree_sensitive() kerneldoc and adding
      a kzfree backward compatibility macro in slab.h.
      
      [akpm@linux-foundation.org: fs/crypto/inline_crypt.c needs linux/slab.h]
      [akpm@linux-foundation.org: fix fs/crypto/inline_crypt.c some more]
      Suggested-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NWaiman Long <longman@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: "Jason A . Donenfeld" <Jason@zx2c4.com>
      Link: http://lkml.kernel.org/r/20200616154311.12314-3-longman@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      453431a5
  15. 24 7月, 2020 1 次提交
    • M
      dm integrity: fix integrity recalculation that is improperly skipped · 5df96f2b
      Mikulas Patocka 提交于
      Commit adc0daad ("dm: report suspended
      device during destroy") broke integrity recalculation.
      
      The problem is dm_suspended() returns true not only during suspend,
      but also during resume. So this race condition could occur:
      1. dm_integrity_resume calls queue_work(ic->recalc_wq, &ic->recalc_work)
      2. integrity_recalc (&ic->recalc_work) preempts the current thread
      3. integrity_recalc calls if (unlikely(dm_suspended(ic->ti))) goto unlock_ret;
      4. integrity_recalc exits and no recalculating is done.
      
      To fix this race condition, add a function dm_post_suspending that is
      only true during the postsuspend phase and use it instead of
      dm_suspended().
      
      Signed-off-by: Mikulas Patocka <mpatocka redhat com>
      Fixes: adc0daad ("dm: report suspended device during destroy")
      Cc: stable vger kernel org # v4.18+
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      5df96f2b
  16. 01 7月, 2020 1 次提交
  17. 22 5月, 2020 1 次提交
  18. 21 5月, 2020 1 次提交
    • G
      dm: replace zero-length array with flexible-array · b18ae8dd
      Gustavo A. R. Silva 提交于
      The current codebase makes use of the zero-length array language
      extension to the C90 standard, but the preferred mechanism to declare
      variable-length types such as these ones is a flexible array member[1][2],
      introduced in C99:
      
      struct foo {
              int stuff;
              struct boo array[];
      };
      
      By making use of the mechanism above, we will get a compiler warning
      in case the flexible array does not occur last in the structure, which
      will help us prevent some kind of undefined behavior bugs from being
      inadvertently introduced[3] to the codebase from now on.
      
      Also, notice that, dynamic memory allocations won't be affected by
      this change:
      
      "Flexible array members have incomplete type, and so the sizeof operator
      may not be applied. As a quirk of the original implementation of
      zero-length arrays, sizeof evaluates to zero."[1]
      
      sizeof(flexible-array-member) triggers a warning because flexible array
      members have incomplete type[1]. There are some instances of code in
      which the sizeof operator is being incorrectly/erroneously applied to
      zero-length arrays and the result is zero. Such instances may be hiding
      some bugs. So, this work (flexible-array member conversions) will also
      help to get completely rid of those sorts of issues.
      
      This issue was found with the help of Coccinelle.
      
      [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
      [2] https://github.com/KSPP/linux/issues/21
      [3] commit 76497732 ("cxgb3/l2t: Fix undefined behaviour")
      Signed-off-by: NGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      b18ae8dd
  19. 15 5月, 2020 1 次提交
  20. 04 4月, 2020 1 次提交
  21. 03 4月, 2020 1 次提交
    • M
      dm integrity: fix ppc64le warning · e7fc1e57
      Mike Snitzer 提交于
      Otherwise:
      
      In file included from drivers/md/dm-integrity.c:13:
      drivers/md/dm-integrity.c: In function 'dm_integrity_status':
      drivers/md/dm-integrity.c:3061:10: error: format '%llu' expects
      argument of type 'long long unsigned int', but argument 4 has type
      'long int' [-Werror=format=]
         DMEMIT("%llu %llu",
                ^~~~~~~~~~~
          atomic64_read(&ic->number_of_mismatches),
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ./include/linux/device-mapper.h:550:46: note: in definition of macro 'DMEMIT'
            0 : scnprintf(result + sz, maxlen - sz, x))
                                                    ^
      cc1: all warnings being treated as errors
      
      Fixes: 7649194a ("dm integrity: remove sector type casts")
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      e7fc1e57
  22. 25 3月, 2020 7 次提交
  23. 24 3月, 2020 1 次提交
  24. 04 3月, 2020 1 次提交
    • M
      dm: bump version of core and various targets · 636be424
      Mike Snitzer 提交于
      Changes made during the 5.6 cycle warrant bumping the version number
      for DM core and the targets modified by this commit.
      
      It should be noted that dm-thin, dm-crypt and dm-raid already had
      their target version bumped during the 5.6 merge window.
      
      Signed-off-by; Mike Snitzer <snitzer@redhat.com>
      636be424
  25. 03 3月, 2020 1 次提交
  26. 28 2月, 2020 1 次提交
    • M
      dm: report suspended device during destroy · adc0daad
      Mikulas Patocka 提交于
      The function dm_suspended returns true if the target is suspended.
      However, when the target is being suspended during unload, it returns
      false.
      
      An example where this is a problem: the test "!dm_suspended(wc->ti)" in
      writecache_writeback is not sufficient, because dm_suspended returns
      zero while writecache_suspend is in progress.  As is, without an
      enhanced dm_suspended, simply switching from flush_workqueue to
      drain_workqueue still emits warnings:
      workqueue writecache-writeback: drain_workqueue() isn't complete after 10 tries
      workqueue writecache-writeback: drain_workqueue() isn't complete after 100 tries
      workqueue writecache-writeback: drain_workqueue() isn't complete after 200 tries
      workqueue writecache-writeback: drain_workqueue() isn't complete after 300 tries
      workqueue writecache-writeback: drain_workqueue() isn't complete after 400 tries
      
      writecache_suspend calls flush_workqueue(wc->writeback_wq) - this function
      flushes the current work. However, the workqueue may re-queue itself and
      flush_workqueue doesn't wait for re-queued works to finish. Because of
      this - the function writecache_writeback continues execution after the
      device was suspended and then concurrently with writecache_dtr, causing
      a crash in writecache_writeback.
      
      We must use drain_workqueue - that waits until the work and all re-queued
      works finish.
      
      As a prereq for switching to drain_workqueue, this commit fixes
      dm_suspended to return true after the presuspend hook and before the
      postsuspend hook - just like during a normal suspend. It allows
      simplifying the dm-integrity and dm-writecache targets so that they
      don't have to maintain suspended flags on their own.
      
      With this change use of drain_workqueue() can be used effectively.  This
      change was tested with the lvm2 testsuite and cryptsetup testsuite and
      the are no regressions.
      
      Fixes: 48debafe ("dm: add writecache target")
      Cc: stable@vger.kernel.org # 4.18+
      Reported-by: NCorey Marthaler <cmarthal@redhat.com>
      Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      adc0daad
  27. 26 2月, 2020 3 次提交