1. 05 1月, 2021 2 次提交
    • I
      dm crypt: use GFP_ATOMIC when allocating crypto requests from softirq · d68b2958
      Ignat Korchagin 提交于
      Commit 39d42fa9 ("dm crypt: add flags to optionally bypass kcryptd
      workqueues") made it possible for some code paths in dm-crypt to be
      executed in softirq context, when the underlying driver processes IO
      requests in interrupt/softirq context.
      
      In this case sometimes when allocating a new crypto request we may get
      a stacktrace like below:
      
      [  210.103008][    C0] BUG: sleeping function called from invalid context at mm/mempool.c:381
      [  210.104746][    C0] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 2602, name: fio
      [  210.106599][    C0] CPU: 0 PID: 2602 Comm: fio Tainted: G        W         5.10.0+ #50
      [  210.108331][    C0] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015
      [  210.110212][    C0] Call Trace:
      [  210.110921][    C0]  <IRQ>
      [  210.111527][    C0]  dump_stack+0x7d/0xa3
      [  210.112411][    C0]  ___might_sleep.cold+0x122/0x151
      [  210.113527][    C0]  mempool_alloc+0x16b/0x2f0
      [  210.114524][    C0]  ? __queue_work+0x515/0xde0
      [  210.115553][    C0]  ? mempool_resize+0x700/0x700
      [  210.116586][    C0]  ? crypt_endio+0x91/0x180
      [  210.117479][    C0]  ? blk_update_request+0x757/0x1150
      [  210.118513][    C0]  ? blk_mq_end_request+0x4b/0x480
      [  210.119572][    C0]  ? blk_done_softirq+0x21d/0x340
      [  210.120628][    C0]  ? __do_softirq+0x190/0x611
      [  210.121626][    C0]  crypt_convert+0x29f9/0x4c00
      [  210.122668][    C0]  ? _raw_spin_lock_irqsave+0x87/0xe0
      [  210.123824][    C0]  ? kasan_set_track+0x1c/0x30
      [  210.124858][    C0]  ? crypt_iv_tcw_ctr+0x4a0/0x4a0
      [  210.125930][    C0]  ? kmem_cache_free+0x104/0x470
      [  210.126973][    C0]  ? crypt_endio+0x91/0x180
      [  210.127947][    C0]  kcryptd_crypt_read_convert+0x30e/0x420
      [  210.129165][    C0]  blk_update_request+0x757/0x1150
      [  210.130231][    C0]  blk_mq_end_request+0x4b/0x480
      [  210.131294][    C0]  blk_done_softirq+0x21d/0x340
      [  210.132332][    C0]  ? _raw_spin_lock+0x81/0xd0
      [  210.133289][    C0]  ? blk_mq_stop_hw_queue+0x30/0x30
      [  210.134399][    C0]  ? _raw_read_lock_irq+0x40/0x40
      [  210.135458][    C0]  __do_softirq+0x190/0x611
      [  210.136409][    C0]  ? handle_edge_irq+0x221/0xb60
      [  210.137447][    C0]  asm_call_irq_on_stack+0x12/0x20
      [  210.138507][    C0]  </IRQ>
      [  210.139118][    C0]  do_softirq_own_stack+0x37/0x40
      [  210.140191][    C0]  irq_exit_rcu+0x110/0x1b0
      [  210.141151][    C0]  common_interrupt+0x74/0x120
      [  210.142171][    C0]  asm_common_interrupt+0x1e/0x40
      
      Fix this by allocating crypto requests with GFP_ATOMIC mask in
      interrupt context.
      
      Fixes: 39d42fa9 ("dm crypt: add flags to optionally bypass kcryptd workqueues")
      Cc: stable@vger.kernel.org # v5.9+
      Reported-by: NMaciej S. Szmigiero <mail@maciej.szmigiero.name>
      Signed-off-by: NIgnat Korchagin <ignat@cloudflare.com>
      Acked-by: NMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      d68b2958
    • I
      dm crypt: do not wait for backlogged crypto request completion in softirq · 8abec36d
      Ignat Korchagin 提交于
      Commit 39d42fa9 ("dm crypt: add flags to optionally bypass kcryptd
      workqueues") made it possible for some code paths in dm-crypt to be
      executed in softirq context, when the underlying driver processes IO
      requests in interrupt/softirq context.
      
      When Crypto API backlogs a crypto request, dm-crypt uses
      wait_for_completion to avoid sending further requests to an already
      overloaded crypto driver. However, if the code is executing in softirq
      context, we might get the following stacktrace:
      
      [  210.235213][    C0] BUG: scheduling while atomic: fio/2602/0x00000102
      [  210.236701][    C0] Modules linked in:
      [  210.237566][    C0] CPU: 0 PID: 2602 Comm: fio Tainted: G        W         5.10.0+ #50
      [  210.239292][    C0] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015
      [  210.241233][    C0] Call Trace:
      [  210.241946][    C0]  <IRQ>
      [  210.242561][    C0]  dump_stack+0x7d/0xa3
      [  210.243466][    C0]  __schedule_bug.cold+0xb3/0xc2
      [  210.244539][    C0]  __schedule+0x156f/0x20d0
      [  210.245518][    C0]  ? io_schedule_timeout+0x140/0x140
      [  210.246660][    C0]  schedule+0xd0/0x270
      [  210.247541][    C0]  schedule_timeout+0x1fb/0x280
      [  210.248586][    C0]  ? usleep_range+0x150/0x150
      [  210.249624][    C0]  ? unpoison_range+0x3a/0x60
      [  210.250632][    C0]  ? ____kasan_kmalloc.constprop.0+0x82/0xa0
      [  210.251949][    C0]  ? unpoison_range+0x3a/0x60
      [  210.252958][    C0]  ? __prepare_to_swait+0xa7/0x190
      [  210.254067][    C0]  do_wait_for_common+0x2ab/0x370
      [  210.255158][    C0]  ? usleep_range+0x150/0x150
      [  210.256192][    C0]  ? bit_wait_io_timeout+0x160/0x160
      [  210.257358][    C0]  ? blk_update_request+0x757/0x1150
      [  210.258582][    C0]  ? _raw_spin_lock_irq+0x82/0xd0
      [  210.259674][    C0]  ? _raw_read_unlock_irqrestore+0x30/0x30
      [  210.260917][    C0]  wait_for_completion+0x4c/0x90
      [  210.261971][    C0]  crypt_convert+0x19a6/0x4c00
      [  210.263033][    C0]  ? _raw_spin_lock_irqsave+0x87/0xe0
      [  210.264193][    C0]  ? kasan_set_track+0x1c/0x30
      [  210.265191][    C0]  ? crypt_iv_tcw_ctr+0x4a0/0x4a0
      [  210.266283][    C0]  ? kmem_cache_free+0x104/0x470
      [  210.267363][    C0]  ? crypt_endio+0x91/0x180
      [  210.268327][    C0]  kcryptd_crypt_read_convert+0x30e/0x420
      [  210.269565][    C0]  blk_update_request+0x757/0x1150
      [  210.270563][    C0]  blk_mq_end_request+0x4b/0x480
      [  210.271680][    C0]  blk_done_softirq+0x21d/0x340
      [  210.272775][    C0]  ? _raw_spin_lock+0x81/0xd0
      [  210.273847][    C0]  ? blk_mq_stop_hw_queue+0x30/0x30
      [  210.275031][    C0]  ? _raw_read_lock_irq+0x40/0x40
      [  210.276182][    C0]  __do_softirq+0x190/0x611
      [  210.277203][    C0]  ? handle_edge_irq+0x221/0xb60
      [  210.278340][    C0]  asm_call_irq_on_stack+0x12/0x20
      [  210.279514][    C0]  </IRQ>
      [  210.280164][    C0]  do_softirq_own_stack+0x37/0x40
      [  210.281281][    C0]  irq_exit_rcu+0x110/0x1b0
      [  210.282286][    C0]  common_interrupt+0x74/0x120
      [  210.283376][    C0]  asm_common_interrupt+0x1e/0x40
      [  210.284496][    C0] RIP: 0010:_aesni_enc1+0x65/0xb0
      
      Fix this by making crypt_convert function reentrant from the point of
      a single bio and make dm-crypt defer further bio processing to a
      workqueue, if Crypto API backlogs a request in interrupt context.
      
      Fixes: 39d42fa9 ("dm crypt: add flags to optionally bypass kcryptd workqueues")
      Cc: stable@vger.kernel.org # v5.9+
      Signed-off-by: NIgnat Korchagin <ignat@cloudflare.com>
      Acked-by: NMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      8abec36d
  2. 29 12月, 2020 1 次提交
  3. 05 12月, 2020 2 次提交
  4. 30 9月, 2020 1 次提交
  5. 02 9月, 2020 1 次提交
  6. 24 8月, 2020 1 次提交
  7. 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
  8. 20 7月, 2020 2 次提交
    • D
      dm crypt: Enable zoned block device support · 8e225f04
      Damien Le Moal 提交于
      Enable support for zoned block devices. This is done by:
      1) implementing the target report_zones method.
      2) adding the DM_TARGET_ZONED_HM flag to the target features.
      3) setting DM_CRYPT_NO_WRITE_WORKQUEUE flag to avoid IO
         processing via workqueue.
      4) Introducing inline write encryption completion to preserve write
         ordering.
      
      The last point is implemented by introducing the internal flag
      DM_CRYPT_WRITE_INLINE. When set, kcryptd_crypt_write_convert() always
      waits inline for the completion of a write request encryption if the
      request is not already completed once crypt_convert() returns.
      Completion of write request encryption is signaled using the
      restart completion by kcryptd_async_done(). This mechanism allows
      using ciphers that have an asynchronous implementation, isolating
      dm-crypt from any potential request completion reordering for these
      ciphers.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      8e225f04
    • I
      dm crypt: add flags to optionally bypass kcryptd workqueues · 39d42fa9
      Ignat Korchagin 提交于
      This is a follow up to [1] that detailed latency problems associated
      with dm-crypt's use of workqueues when processing IO.
      
      Current dm-crypt implementation creates a significant IO performance
      overhead (at least on small IO block sizes) for both latency and
      throughput. We suspect offloading IO request processing into
      workqueues and async threads is more harmful these days with the
      modern fast storage. I also did some digging into the dm-crypt git
      history and much of this async processing is not needed anymore,
      because the reasons it was added are mostly gone from the kernel. More
      details can be found in [2] (see "Git archeology" section).
      
      This change adds DM_CRYPT_NO_READ_WORKQUEUE and
      DM_CRYPT_NO_WRITE_WORKQUEUE flags for read and write BIOs, which
      direct dm-crypt to not offload crypto operations into kcryptd
      workqueues.  In addition, writes are not buffered to be sorted in the
      dm-crypt red-black tree, but dispatched immediately. For cases, where
      crypto operations cannot happen (hard interrupt context, for example
      the read path of some NVME drivers), we offload the work to a tasklet
      rather than a workqueue.
      
      These flags only ensure no async BIO processing in the dm-crypt
      module. It is worth noting that some Crypto API implementations may
      offload encryption into their own workqueues, which are independent of
      the dm-crypt and its configuration. However upon enabling these new
      flags dm-crypt will instruct Crypto API not to backlog crypto
      requests.
      
      To give an idea of the performance gains for certain workloads,
      consider the script, and results when tested against various
      devices, detailed here:
      https://www.redhat.com/archives/dm-devel/2020-July/msg00138.html
      
      [1]: https://www.spinics.net/lists/dm-crypt/msg07516.html
      [2]: https://blog.cloudflare.com/speeding-up-linux-disk-encryption/Signed-off-by: NIgnat Korchagin <ignat@cloudflare.com>
      Reviewed-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NBob Liu <bob.liu@oracle.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      39d42fa9
  9. 06 7月, 2020 1 次提交
  10. 01 7月, 2020 1 次提交
  11. 06 6月, 2020 1 次提交
  12. 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
  13. 15 5月, 2020 1 次提交
  14. 24 3月, 2020 1 次提交
  15. 15 1月, 2020 2 次提交
  16. 08 1月, 2020 1 次提交
  17. 21 11月, 2019 1 次提交
  18. 04 9月, 2019 2 次提交
  19. 23 8月, 2019 1 次提交
    • A
      dm crypt: reuse eboiv skcipher for IV generation · 39d13a1a
      Ard Biesheuvel 提交于
      Instead of instantiating a separate cipher to perform the encryption
      needed to produce the IV, reuse the skcipher used for the block data
      and invoke it one additional time for each block to encrypt a zero
      vector and use the output as the IV.
      
      For CBC mode, this is equivalent to using the bare block cipher, but
      without the risk of ending up with a non-time invariant implementation
      of AES when the skcipher itself is time variant (e.g., arm64 without
      Crypto Extensions has a NEON based time invariant implementation of
      cbc(aes) but no time invariant implementation of the core cipher other
      than aes-ti, which is not enabled by default).
      
      This approach is a compromise between dm-crypt API flexibility and
      reducing dependence on parts of the crypto API that should not usually
      be exposed to other subsystems, such as the bare cipher API.
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Tested-by: NMilan Broz <gmazyland@gmail.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      39d13a1a
  20. 11 7月, 2019 1 次提交
  21. 10 7月, 2019 4 次提交
  22. 28 6月, 2019 1 次提交
    • D
      keys: Replace uid/gid/perm permissions checking with an ACL · 2e12256b
      David Howells 提交于
      Replace the uid/gid/perm permissions checking on a key with an ACL to allow
      the SETATTR and SEARCH permissions to be split.  This will also allow a
      greater range of subjects to represented.
      
      ============
      WHY DO THIS?
      ============
      
      The problem is that SETATTR and SEARCH cover a slew of actions, not all of
      which should be grouped together.
      
      For SETATTR, this includes actions that are about controlling access to a
      key:
      
       (1) Changing a key's ownership.
      
       (2) Changing a key's security information.
      
       (3) Setting a keyring's restriction.
      
      And actions that are about managing a key's lifetime:
      
       (4) Setting an expiry time.
      
       (5) Revoking a key.
      
      and (proposed) managing a key as part of a cache:
      
       (6) Invalidating a key.
      
      Managing a key's lifetime doesn't really have anything to do with
      controlling access to that key.
      
      Expiry time is awkward since it's more about the lifetime of the content
      and so, in some ways goes better with WRITE permission.  It can, however,
      be set unconditionally by a process with an appropriate authorisation token
      for instantiating a key, and can also be set by the key type driver when a
      key is instantiated, so lumping it with the access-controlling actions is
      probably okay.
      
      As for SEARCH permission, that currently covers:
      
       (1) Finding keys in a keyring tree during a search.
      
       (2) Permitting keyrings to be joined.
      
       (3) Invalidation.
      
      But these don't really belong together either, since these actions really
      need to be controlled separately.
      
      Finally, there are number of special cases to do with granting the
      administrator special rights to invalidate or clear keys that I would like
      to handle with the ACL rather than key flags and special checks.
      
      
      ===============
      WHAT IS CHANGED
      ===============
      
      The SETATTR permission is split to create two new permissions:
      
       (1) SET_SECURITY - which allows the key's owner, group and ACL to be
           changed and a restriction to be placed on a keyring.
      
       (2) REVOKE - which allows a key to be revoked.
      
      The SEARCH permission is split to create:
      
       (1) SEARCH - which allows a keyring to be search and a key to be found.
      
       (2) JOIN - which allows a keyring to be joined as a session keyring.
      
       (3) INVAL - which allows a key to be invalidated.
      
      The WRITE permission is also split to create:
      
       (1) WRITE - which allows a key's content to be altered and links to be
           added, removed and replaced in a keyring.
      
       (2) CLEAR - which allows a keyring to be cleared completely.  This is
           split out to make it possible to give just this to an administrator.
      
       (3) REVOKE - see above.
      
      
      Keys acquire ACLs which consist of a series of ACEs, and all that apply are
      unioned together.  An ACE specifies a subject, such as:
      
       (*) Possessor - permitted to anyone who 'possesses' a key
       (*) Owner - permitted to the key owner
       (*) Group - permitted to the key group
       (*) Everyone - permitted to everyone
      
      Note that 'Other' has been replaced with 'Everyone' on the assumption that
      you wouldn't grant a permit to 'Other' that you wouldn't also grant to
      everyone else.
      
      Further subjects may be made available by later patches.
      
      The ACE also specifies a permissions mask.  The set of permissions is now:
      
      	VIEW		Can view the key metadata
      	READ		Can read the key content
      	WRITE		Can update/modify the key content
      	SEARCH		Can find the key by searching/requesting
      	LINK		Can make a link to the key
      	SET_SECURITY	Can change owner, ACL, expiry
      	INVAL		Can invalidate
      	REVOKE		Can revoke
      	JOIN		Can join this keyring
      	CLEAR		Can clear this keyring
      
      
      The KEYCTL_SETPERM function is then deprecated.
      
      The KEYCTL_SET_TIMEOUT function then is permitted if SET_SECURITY is set,
      or if the caller has a valid instantiation auth token.
      
      The KEYCTL_INVALIDATE function then requires INVAL.
      
      The KEYCTL_REVOKE function then requires REVOKE.
      
      The KEYCTL_JOIN_SESSION_KEYRING function then requires JOIN to join an
      existing keyring.
      
      The JOIN permission is enabled by default for session keyrings and manually
      created keyrings only.
      
      
      ======================
      BACKWARD COMPATIBILITY
      ======================
      
      To maintain backward compatibility, KEYCTL_SETPERM will translate the
      permissions mask it is given into a new ACL for a key - unless
      KEYCTL_SET_ACL has been called on that key, in which case an error will be
      returned.
      
      It will convert possessor, owner, group and other permissions into separate
      ACEs, if each portion of the mask is non-zero.
      
      SETATTR permission turns on all of INVAL, REVOKE and SET_SECURITY.  WRITE
      permission turns on WRITE, REVOKE and, if a keyring, CLEAR.  JOIN is turned
      on if a keyring is being altered.
      
      The KEYCTL_DESCRIBE function translates the ACL back into a permissions
      mask to return depending on possessor, owner, group and everyone ACEs.
      
      It will make the following mappings:
      
       (1) INVAL, JOIN -> SEARCH
      
       (2) SET_SECURITY -> SETATTR
      
       (3) REVOKE -> WRITE if SETATTR isn't already set
      
       (4) CLEAR -> WRITE
      
      Note that the value subsequently returned by KEYCTL_DESCRIBE may not match
      the value set with KEYCTL_SETATTR.
      
      
      =======
      TESTING
      =======
      
      This passes the keyutils testsuite for all but a couple of tests:
      
       (1) tests/keyctl/dh_compute/badargs: The first wrong-key-type test now
           returns EOPNOTSUPP rather than ENOKEY as READ permission isn't removed
           if the type doesn't have ->read().  You still can't actually read the
           key.
      
       (2) tests/keyctl/permitting/valid: The view-other-permissions test doesn't
           work as Other has been replaced with Everyone in the ACL.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      2e12256b
  23. 16 5月, 2019 2 次提交
  24. 30 4月, 2019 1 次提交
  25. 25 4月, 2019 1 次提交
    • E
      crypto: shash - remove shash_desc::flags · 877b5691
      Eric Biggers 提交于
      The flags field in 'struct shash_desc' never actually does anything.
      The only ostensibly supported flag is CRYPTO_TFM_REQ_MAY_SLEEP.
      However, no shash algorithm ever sleeps, making this flag a no-op.
      
      With this being the case, inevitably some users who can't sleep wrongly
      pass MAY_SLEEP.  These would all need to be fixed if any shash algorithm
      actually started sleeping.  For example, the shash_ahash_*() functions,
      which wrap a shash algorithm with the ahash API, pass through MAY_SLEEP
      from the ahash API to the shash API.  However, the shash functions are
      called under kmap_atomic(), so actually they're assumed to never sleep.
      
      Even if it turns out that some users do need preemption points while
      hashing large buffers, we could easily provide a helper function
      crypto_shash_update_large() which divides the data into smaller chunks
      and calls crypto_shash_update() and cond_resched() for each chunk.  It's
      not necessary to have a flag in 'struct shash_desc', nor is it necessary
      to make individual shash algorithms aware of this at all.
      
      Therefore, remove shash_desc::flags, and document that the
      crypto_shash_*() functions can be called from any context.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      877b5691
  26. 19 4月, 2019 1 次提交
  27. 15 2月, 2019 1 次提交
  28. 12 2月, 2019 1 次提交
    • M
      dm crypt: don't overallocate the integrity tag space · ff0c129d
      Mikulas Patocka 提交于
      bio_sectors() returns the value in the units of 512-byte sectors (no
      matter what the real sector size of the device).  dm-crypt multiplies
      bio_sectors() by on_disk_tag_size to calculate the space allocated for
      integrity tags.  If dm-crypt is running with sector size larger than
      512b, it allocates more data than is needed.
      
      Device Mapper trims the extra space when passing the bio to
      dm-integrity, so this bug didn't result in any visible misbehavior.
      But it must be fixed to avoid wasteful memory allocation for the block
      integrity payload.
      
      Fixes: ef43aa38 ("dm crypt: add cryptographic data integrity protection (authenticated encryption)")
      Cc: stable@vger.kernel.org # 4.12+
      Reported-by: NMilan Broz <mbroz@redhat.com>
      Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      ff0c129d
  29. 11 1月, 2019 1 次提交
    • M
      dm crypt: fix parsing of extended IV arguments · 1856b9f7
      Milan Broz 提交于
      The dm-crypt cipher specification in a mapping table is defined as:
        cipher[:keycount]-chainmode-ivmode[:ivopts]
      or (new crypt API format):
        capi:cipher_api_spec-ivmode[:ivopts]
      
      For ESSIV, the parameter includes hash specification, for example:
      aes-cbc-essiv:sha256
      
      The implementation expected that additional IV option to never include
      another dash '-' character.
      
      But, with SHA3, there are names like sha3-256; so the mapping table
      parser fails:
      
      dmsetup create test --table "0 8 crypt aes-cbc-essiv:sha3-256 9c1185a5c5e9fc54612808977ee8f5b9e 0 /dev/sdb 0"
        or (new crypt API format)
      dmsetup create test --table "0 8 crypt capi:cbc(aes)-essiv:sha3-256 9c1185a5c5e9fc54612808977ee8f5b9e 0 /dev/sdb 0"
      
        device-mapper: crypt: Ignoring unexpected additional cipher options
        device-mapper: table: 253:0: crypt: Error creating IV
        device-mapper: ioctl: error adding target to table
      
      Fix the dm-crypt constructor to ignore additional dash in IV options and
      also remove a bogus warning (that is ignored anyway).
      
      Cc: stable@vger.kernel.org # 4.12+
      Signed-off-by: NMilan Broz <gmazyland@gmail.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      1856b9f7
  30. 29 12月, 2018 1 次提交
  31. 18 12月, 2018 1 次提交
    • E
      dm crypt: log the encryption algorithm implementation · af331eba
      Eric Biggers 提交于
      Log the encryption algorithm's driver name when a dm-crypt target is
      created.  This will help people determine whether the expected
      implementation is being used.  In some cases we've seen people do
      benchmarks and reject using encryption for performance reasons, when in
      fact they used a much slower implementation than was possible on the
      hardware.  It can make an enormous difference; e.g., AES-XTS on ARM can
      be over 10x faster with the crypto extensions than without.  It can also
      be useful to know if an implementation using an external crypto
      accelerator is being used instead of a software implementation.
      
      Example message:
      
      [   29.307629] device-mapper: crypt: xts(aes) using implementation "xts-aes-ce"
      
      We've already found the similar message in fs/crypto/keyinfo.c to be
      very useful.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      af331eba