Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1609677pxb; Wed, 10 Feb 2021 12:20:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHQs4Z5M2GZ9JDTptYOLh+hA6inBqnaGh1wqI4073d9AHaKJ1O6UTJ/+CZ6Deg8hVEx+1+ X-Received: by 2002:a05:6402:27cf:: with SMTP id c15mr4807107ede.179.1612988428853; Wed, 10 Feb 2021 12:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612988428; cv=none; d=google.com; s=arc-20160816; b=v+ZQdz+XCTU0DbQWZQUOUwaeJ5VXMWmfBG/lrOzAcILzdu6NTKcTVQj9dMfmNdy5wu tw9WjyKVEZbOBMCRCaXmtu9HZCDTN/LgdvzhsxeaKS+b28ufw8zil6O6TmkYLC4BJ3cr 0kYRvi0S7IXj+ldcnLeU9Iqdin4cVZDFi+FQthnjO2MCDMh0TNDMEoeb9zgWaONlFI3L Kq/9g6RIR6W+CAkTMn5JvtoRSfGFCGVxjk0RrteY2KjE8+1pS9Es8IO31PEQX00EUqvf mAXQ9B17BsMT4NWv+tZkLB7usgv2O0TIPPGrxTw092Jt+mnaV5gAaCDYi1bOovFARcy9 Y1bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sUeoC6NQL6M2N02SKTaixnXIVPtC2uo2ZE2Yg+kWcT0=; b=I2FNkBlZBFfm6qE4gMjZPSudGUOjp+pzHSaAcM5ZBvslAa2NRrhkIfEF82WmUad6m9 BhxzfnyPIXSw8uQzJyoouqtKQkbcXBjSa+TQjYsLBspKHJqTynscjNhN0hirDw1NYE4I OGOe5tgAw+gWKDRQVrcOYoWE+sC9SmkrOBD7Ywvyv5B4oUwcU6fYwOQjAOco/g02GVnq i5jlexkH1J18iMnOpJgCRnxoBsU00J70i1JDvKZZk1BA/NBetI/5kmScUU0UYBUYnsbr ooXtBobKi+9qoTQDxzVoy1DSDWjBSVb41AvL0bggAwCR3lh62e5chc+/9pY/zzA5USGl uJUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o9Xq5CmG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si1977613ejx.70.2021.02.10.12.20.03; Wed, 10 Feb 2021 12:20:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o9Xq5CmG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232462AbhBJUSe (ORCPT + 99 others); Wed, 10 Feb 2021 15:18:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:44274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233006AbhBJUSN (ORCPT ); Wed, 10 Feb 2021 15:18:13 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DFADF64EDA; Wed, 10 Feb 2021 20:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612988252; bh=duG8pcJD/SQDOexeoDS0AUNveV9rZeSlys1CA4SiQKc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=o9Xq5CmGvyh/FHBiLWee94tGEaUkh8NEJhVFvFOphV6Xme2C6lLt4AIDMealmukNf WzPatCdYxLbBYXnDp+Mfns4uwVin07t2GfOtwKLAk92j+3IVgFdf65F1/Yrc6jDexm NknDEsChSyI1DrVwk8UpxjMT/XUdAxsaFwYQogdTNyleTiNOF4UU9PhbiAB5Z+IZsa gi1el5PAW1+ZYQmzfqcafBI9dUvRQ1vpQDBUI9/ZMgj16Y1v0tAmjh7pwxdXN30MiY vBq3MrUCn+PFQR2x/kGC1UUYIoSPfDXKFDWWdK2ywftRAdCeXd375Sb0xdu5Kuip2v UlwSZvsSPsV4Q== Date: Wed, 10 Feb 2021 12:17:30 -0800 From: Eric Biggers To: Satya Tangirala Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Jens Axboe , Mike Snitzer , Alasdair Kergon Subject: Re: [PATCH v4 3/5] dm: add support for passing through inline crypto support Message-ID: References: <20210201051019.1174983-1-satyat@google.com> <20210201051019.1174983-4-satyat@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210201051019.1174983-4-satyat@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 01, 2021 at 05:10:17AM +0000, Satya Tangirala wrote: > 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: Eric Biggers > Signed-off-by: Eric Biggers > Signed-off-by: Satya Tangirala I don't see any obvious issues with this latest version. I assume you've tested it on real hardware? If it's needed despite my Co-developed-by, feel free to add: Reviewed-by: Eric Biggers A few nits about comments, in case you resend: > diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h > index 086d293c2b03..bf3e66f39a4a 100644 > --- a/drivers/md/dm-core.h > +++ b/drivers/md/dm-core.h > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > > #include > > @@ -162,6 +163,10 @@ struct dm_table { > void *event_context; > > struct dm_md_mempools *mempools; > + > +#ifdef CONFIG_BLK_INLINE_ENCRYPTION > + struct blk_keyslot_manager *ksm; > +#endif > }; It might be helpful if there was a brief comment here that explained that this field is only set temporarily while the table is being set up, and it gets set to NULL after the capabilities have been transferred to the request_queue. I.e., it's not something that stays around here while the dm device is active. > +/* > + * Constructs and returns a keyslot manager that represents the crypto > + * capabilities of the devices described by the dm_table. However, if the > + * constructed keyslot manager does not support a superset of the crypto > + * capabilities supported by the current keyslot manager of the mapped_device, > + * it returns an error instead, since we don't support restricting crypto > + * capabilities on table changes. Finally, if the constructed keyslot manager > + * doesn't actually support any crypto modes at all, it just returns NULL. > + */ > +static int > +dm_table_construct_keyslot_manager(struct dm_table *t) This doesn't "return" the keyslot manager anymore, but rather assigns it to t->ksm. It would also be helpful if the comment explicitly mentioned that the goal is to find the capabilities that all the devices have in common. E.g. "Initializes t->ksm with a keyslot manager that represents the common set of crypto capabilities of the devices described by the dm_table.". > diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h > index 61a66fb8ebb3..d2142f5a82a7 100644 > --- a/include/linux/device-mapper.h > +++ b/include/linux/device-mapper.h > @@ -257,6 +257,12 @@ struct target_type { > #define DM_TARGET_NOWAIT 0x00000080 > #define dm_target_supports_nowait(type) ((type)->features & DM_TARGET_NOWAIT) > > +/* > + * > + */ > +#define DM_TARGET_PASSES_CRYPTO 0x00000100 > +#define dm_target_passes_crypto(type) ((type)->features & DM_TARGET_PASSES_CRYPTO) The above comment isn't very useful :-) - Eric