mbox series

[0/5] blk-crypto cleanups

Message ID 20210913013135.102404-1-ebiggers@kernel.org
Headers show
Series blk-crypto cleanups | expand

Message

Eric Biggers Sept. 13, 2021, 1:31 a.m. UTC
This series renames struct blk_keyslot_manager to struct
blk_crypto_profile, as it is misnamed; it doesn't always manage
keyslots.  It's much more logical to think of it as the
"blk-crypto profile" of a device, similar to blk_integrity_profile.

This series also improves the inline-encryption.rst documentation file,
and cleans up blk-crypto-fallback a bit.

This series applies to v5.15-rc1.

Eric Biggers (5):
  blk-crypto-fallback: properly prefix function and struct names
  blk-crypto-fallback: consolidate static variables
  blk-crypto: rename keyslot-manager files to blk-crypto-profile
  blk-crypto: rename blk_keyslot_manager to blk_crypto_profile
  blk-crypto: update inline encryption documentation

 Documentation/block/inline-encryption.rst | 439 ++++++++--------
 block/Makefile                            |   2 +-
 block/blk-crypto-fallback.c               | 330 ++++++------
 block/blk-crypto-profile.c                | 564 +++++++++++++++++++++
 block/blk-crypto.c                        |  27 +-
 block/blk-integrity.c                     |   2 +-
 block/keyslot-manager.c                   | 578 ----------------------
 drivers/md/dm-core.h                      |   4 +-
 drivers/md/dm-table.c                     | 168 +++----
 drivers/md/dm.c                           |  10 +-
 drivers/mmc/core/crypto.c                 |  11 +-
 drivers/mmc/host/cqhci-crypto.c           |  33 +-
 drivers/scsi/ufs/ufshcd-crypto.c          |  32 +-
 drivers/scsi/ufs/ufshcd-crypto.h          |   9 +-
 drivers/scsi/ufs/ufshcd.c                 |   2 +-
 drivers/scsi/ufs/ufshcd.h                 |   6 +-
 include/linux/blk-crypto-profile.h        | 166 +++++++
 include/linux/blkdev.h                    |  18 +-
 include/linux/device-mapper.h             |   4 +-
 include/linux/keyslot-manager.h           | 120 -----
 include/linux/mmc/host.h                  |   4 +-
 21 files changed, 1310 insertions(+), 1219 deletions(-)
 create mode 100644 block/blk-crypto-profile.c
 delete mode 100644 block/keyslot-manager.c
 create mode 100644 include/linux/blk-crypto-profile.h
 delete mode 100644 include/linux/keyslot-manager.h

Comments

Ulf Hansson Sept. 14, 2021, 9:04 a.m. UTC | #1
On Mon, 13 Sept 2021 at 03:35, Eric Biggers <ebiggers@kernel.org> wrote:
>

> From: Eric Biggers <ebiggers@google.com>

>

> In preparation for renaming struct blk_keyslot_manager to struct

> blk_crypto_profile, rename the keyslot-manager.h and keyslot-manager.c

> source files.  Renaming these files separately before making a lot of

> changes to their contents makes it easier for git to understand that

> they were renamed.

>

> Signed-off-by: Eric Biggers <ebiggers@google.com>

> ---

>  block/Makefile                                            | 2 +-

>  block/blk-crypto-fallback.c                               | 2 +-

>  block/{keyslot-manager.c => blk-crypto-profile.c}         | 2 +-

>  block/blk-crypto.c                                        | 2 +-

>  drivers/md/dm-core.h                                      | 2 +-

>  drivers/md/dm.c                                           | 2 +-

>  drivers/mmc/host/cqhci-crypto.c                           | 2 +-

>  drivers/scsi/ufs/ufshcd.h                                 | 2 +-

>  include/linux/{keyslot-manager.h => blk-crypto-profile.h} | 0

>  include/linux/mmc/host.h                                  | 2 +-

>  10 files changed, 9 insertions(+), 9 deletions(-)

>  rename block/{keyslot-manager.c => blk-crypto-profile.c} (99%)

>  rename include/linux/{keyslot-manager.h => blk-crypto-profile.h} (100%)


Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC


[...]

Kind regards
Uffe
Ulf Hansson Sept. 14, 2021, 9:04 a.m. UTC | #2
On Mon, 13 Sept 2021 at 03:35, Eric Biggers <ebiggers@kernel.org> wrote:
>
> From: Eric Biggers <ebiggers@google.com>
>
> blk_keyslot_manager is misnamed because it doesn't necessarily manage
> keyslots.  It actually does several different things:
>
>   - Contains the crypto capabilities of the device.
>
>   - Provides functions to control the inline encryption hardware.
>     Originally these were just for programming/evicting keyslots;
>     however, new functionality (hardware-wrapped keys) will require new
>     functions here which are unrelated to keyslots.  Moreover,
>     device-mapper devices already (ab)use "keyslot_evict" to pass key
>     eviction requests to their underlying devices even though
>     device-mapper devices don't have any keyslots themselves (so it
>     really should be "evict_key", not "keyslot_evict").
>
>   - Sometimes (but not always!) it manages keyslots.  Originally it
>     always did, but device-mapper devices don't have keyslots
>     themselves, so they use a "passthrough keyslot manager" which
>     doesn't actually manage keyslots.  This hack works, but the
>     terminology is unnatural.  Also, some hardware doesn't have keyslots
>     and thus also uses a "passthrough keyslot manager" (support for such
>     hardware is yet to be upstreamed, but it will happen eventually).
>
> Let's stop having keyslot managers which don't actually manage keyslots.
> Instead, rename blk_keyslot_manager to blk_crypto_profile.
>
> This is a fairly big change, since for consistency it also has to update
> keyslot manager-related function names, variable names, and comments --
> not just the actual struct name.  However it's still a fairly
> straightforward change, as it doesn't change any actual functionality.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  block/blk-crypto-fallback.c        |  60 ++--
>  block/blk-crypto-profile.c         | 518 ++++++++++++++---------------
>  block/blk-crypto.c                 |  25 +-
>  block/blk-integrity.c              |   2 +-
>  drivers/md/dm-core.h               |   2 +-
>  drivers/md/dm-table.c              | 168 +++++-----
>  drivers/md/dm.c                    |   8 +-
>  drivers/mmc/core/crypto.c          |  11 +-
>  drivers/mmc/host/cqhci-crypto.c    |  31 +-
>  drivers/scsi/ufs/ufshcd-crypto.c   |  32 +-
>  drivers/scsi/ufs/ufshcd-crypto.h   |   9 +-
>  drivers/scsi/ufs/ufshcd.c          |   2 +-
>  drivers/scsi/ufs/ufshcd.h          |   4 +-
>  include/linux/blk-crypto-profile.h | 164 +++++----
>  include/linux/blkdev.h             |  18 +-
>  include/linux/device-mapper.h      |   4 +-
>  include/linux/mmc/host.h           |   2 +-
>  17 files changed, 548 insertions(+), 512 deletions(-)
>

Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC

[...]

Kind regards
Uffe
Eric Biggers Sept. 14, 2021, 9:52 p.m. UTC | #3
On Sun, Sep 12, 2021 at 06:31:34PM -0700, Eric Biggers wrote:
> diff --git a/block/blk-integrity.c b/block/blk-integrity.c

> index 69a12177dfb62..db656d12050f7 100644

> --- a/block/blk-integrity.c

> +++ b/block/blk-integrity.c

> @@ -411,7 +411,7 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template

>  #ifdef CONFIG_BLK_INLINE_ENCRYPTION

>  	if (disk->queue->ksm) {

>  		pr_warn("blk-integrity: Integrity and hardware inline encryption are not supported together. Disabling hardware inline encryption.\n");

> -		blk_ksm_unregister(disk->queue);

> +		blk_crypto_unregister(disk->queue);

>  	}

>  #endif

>  }


Note, there is a build error here when CONFIG_BLK_DEV_INTEGRITY=y, so I'll have
to send a new version even if there are no other comments.

- Eric
Christoph Hellwig Sept. 15, 2021, 7:36 a.m. UTC | #4
On Sun, Sep 12, 2021 at 06:31:31PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> For clarity, avoid using just the "blk_crypto_" prefix for functions and
> structs that are specific to blk-crypto-fallback.  Instead, use
> "blk_crypto_fallback_".  Some places already did this, but others
> didn't.
> 
> This is also a prerequisite for using "struct blk_crypto_keyslot" to
> mean a generic blk-crypto keyslot (which is what it sounds like).
> Rename the fallback one to "struct blk_crypto_fallback_keyslot".
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>

These names are pretty long, but given that there aren't all the many
of them:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Christoph Hellwig Sept. 15, 2021, 7:45 a.m. UTC | #5
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


It would be nice to keep the blk-crypto* includes together, though.
Eric Biggers Sept. 15, 2021, 5:40 p.m. UTC | #6
On Wed, Sep 15, 2021 at 08:45:00AM +0100, Christoph Hellwig wrote:
> Looks good:

> 

> Reviewed-by: Christoph Hellwig <hch@lst.de>

> 

> It would be nice to keep the blk-crypto* includes together, though.


I don't see any case in which they aren't together.  Unless you're talking about
blk-crypto-internal.h, which is a directory-local header so it doesn't get
grouped with the <linux/*.h> headers.

- Eric
Christoph Hellwig Sept. 16, 2021, 7:42 a.m. UTC | #7
On Wed, Sep 15, 2021 at 10:40:53AM -0700, Eric Biggers wrote:
> > It would be nice to keep the blk-crypto* includes together, though.
> 
> I don't see any case in which they aren't together.  Unless you're talking about
> blk-crypto-internal.h, which is a directory-local header so it doesn't get
> grouped with the <linux/*.h> headers.

You're right.   I skimmed over the patch too quickly.