1. 15 7月, 2022 2 次提交
  2. 10 5月, 2022 1 次提交
  3. 14 4月, 2022 1 次提交
    • M
      dm integrity: fix memory corruption when tag_size is less than digest size · 08c1af8f
      Mikulas Patocka 提交于
      It is possible to set up dm-integrity in such a way that the
      "tag_size" parameter is less than the actual digest size. In this
      situation, a part of the digest beyond tag_size is ignored.
      
      In this case, dm-integrity would write beyond the end of the
      ic->recalc_tags array and corrupt memory. The corruption happened in
      integrity_recalc->integrity_sector_checksum->crypto_shash_final.
      
      Fix this corruption by increasing the tags array so that it has enough
      padding at the end to accomodate the loop in integrity_recalc() being
      able to write a full digest size for the last member of the tags
      array.
      
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@kernel.org>
      08c1af8f
  4. 01 4月, 2022 1 次提交
  5. 07 3月, 2022 1 次提交
  6. 06 1月, 2022 1 次提交
  7. 16 12月, 2021 1 次提交
    • M
      dm integrity: fix data corruption due to improper use of bvec_kmap_local · 1cef171a
      Mike Snitzer 提交于
      Commit 25058d1c ("dm integrity: use bvec_kmap_local in
      __journal_read_write") didn't account for __journal_read_write() later
      adding the biovec's bv_offset. As such using bvec_kmap_local() caused
      the start of the biovec to be skipped.
      
      Trivial test that illustrates data corruption:
      
        # integritysetup format /dev/pmem0
        # integritysetup open /dev/pmem0 integrityroot
        # mkfs.xfs /dev/mapper/integrityroot
        ...
        bad magic number
        bad magic number
        Metadata corruption detected at xfs_sb block 0x0/0x1000
        libxfs_writebufr: write verifer failed on xfs_sb bno 0x0/0x1000
        releasing dirty buffer (bulk) to free list!
      
      Fix this by using kmap_local_page() instead of bvec_kmap_local() in
      __journal_read_write().
      
      Fixes: 25058d1c ("dm integrity: use bvec_kmap_local in __journal_read_write")
      Reported-by: NTony Asleson <tasleson@redhat.com>
      Reviewed-by: NHeinz Mauelshagen <heinzm@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      1cef171a
  8. 02 11月, 2021 2 次提交
  9. 28 10月, 2021 1 次提交
  10. 19 10月, 2021 1 次提交
  11. 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
  12. 17 8月, 2021 1 次提交
  13. 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
  14. 14 5月, 2021 2 次提交
  15. 01 5月, 2021 3 次提交
  16. 20 4月, 2021 1 次提交
  17. 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
  18. 03 2月, 2021 2 次提交
  19. 22 1月, 2021 2 次提交
  20. 13 1月, 2021 1 次提交
  21. 09 1月, 2021 1 次提交
  22. 17 11月, 2020 1 次提交
  23. 02 9月, 2020 1 次提交
  24. 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
  25. 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
  26. 01 7月, 2020 1 次提交
  27. 22 5月, 2020 1 次提交
  28. 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
  29. 15 5月, 2020 1 次提交
  30. 04 4月, 2020 1 次提交
  31. 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
  32. 25 3月, 2020 2 次提交