From: Eric Biggers <ebiggers@kernel.org>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: "Gaurav Kashyap (QUIC)" <quic_gaurkash@quicinc.com>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"andersson@kernel.org" <andersson@kernel.org>,
"neil.armstrong@linaro.org" <neil.armstrong@linaro.org>,
"srinivas.kandagatla" <srinivas.kandagatla@linaro.org>,
"krzysztof.kozlowski+dt@linaro.org"
<krzysztof.kozlowski+dt@linaro.org>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
kernel <kernel@quicinc.com>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"Om Prakash Singh (QUIC)" <quic_omprsing@quicinc.com>,
"Bao D. Nguyen (QUIC)" <quic_nguyenb@quicinc.com>,
"bartosz.golaszewski" <bartosz.golaszewski@linaro.org>,
"konrad.dybcio@linaro.org" <konrad.dybcio@linaro.org>,
"ulf.hansson@linaro.org" <ulf.hansson@linaro.org>,
"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"mani@kernel.org" <mani@kernel.org>,
"davem@davemloft.net" <davem@davemloft.net>,
"herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>,
Prasad Sodagudi <psodagud@quicinc.com>,
Sonal Gupta <sonalg@quicinc.com>
Subject: Re: [PATCH v5 04/15] soc: qcom: ice: add hwkm support in ice
Date: Fri, 21 Jun 2024 21:46:24 +0000 [thread overview]
Message-ID: <20240621214624.GA3861295@google.com> (raw)
In-Reply-To: <mwc3zbfst4pnbmxcdmdkhdqgsbrv3vdz5faqc4viifjwk6olfd@gc4pga5huqlv>
On Fri, Jun 21, 2024 at 11:52:01PM +0300, Dmitry Baryshkov wrote:
> On Fri, Jun 21, 2024 at 08:14:41PM GMT, Eric Biggers wrote:
> > On Fri, Jun 21, 2024 at 10:24:07PM +0300, Dmitry Baryshkov wrote:
> > > >
> > > > (fscrypt used to use the keyring service a bit more: it looked up a key whenever
> > > > a file was opened, and it supported evicting per-file keys by revoking the
> > > > corresponding keyring key. But this turned out to be totally broken. E.g., it
> > > > didn't provide the correct semantics for filesystem encryption where the key
> > > > should either be present or absent filesystem-wide.)
> > > >
> > > > We do need the ability to create HW-wrapped keys in long-term wrapped form,
> > > > either via "generate" or "import", return those long-term wrapped keys to
> > > > userspace so that they can be stored on-disk, and convert them into
> > > > ephemerally-wrapped form so they can be used. It probably would be possible to
> > > > support all of this through the keyrings service, but it would need a couple new
> > > > key types:
> > > >
> > > > - One key type that can be instantiated with a raw key (or NULL to request
> > > > generation of a key) and that automagically creates a long-term wrapped key
> > > > and supports userspace reading it back. This would be vaguely similar to
> > > > "trusted", but without any support for using the key directly.
> > > >
> > > > - One key type that can be instantiated using a long-term wrapped key which gets
> > > > automagically converted to an ephemerally-wrapped key. This would be what is
> > > > passed to other kernel subsystems. Functions specific to this key type would
> > > > need to be provided for users to use.
> > >
> > > I think having one key type should be enough. The userspace loads /
> > > generates&reads / wraps and reads back the 'exported' version wrapped
> > > using the platform-specific key. In kernel the key is unsealed and
> > > represented as binary key to be loaded to the hardware + a cookie for
> > > the ephemeral key and device that have been used to wrap it. When
> > > userspace asks the device to program the key, the cookie is verified
> > > to match the device / ephemeral key and then the binary is programmed
> > > to the hardware. Maybe it's enough to use the struct device as a
> > > cookie.
> >
> > The long-term wrapped key has to be wiped from memory as soon as it's no longer
> > needed. So it's hard to see how overloading a key type in this way can work, as
> > the kernel can't know if userspace intends to read back the long-term wrapped
> > key or not.
>
> Why? It should be user's decision. Pretty much in the same way as it's
> done for all other keys.
Sorry, I don't understand what your point is supposed to be here. It's
certainly not okay to leave the long-term wrapped key in memory, since that
destroys the security properties of hardware-wrapped keys. So we need to
provide an API that makes it possible for the long-term wrapped key to be
zeroized. The API you're proposing, as I understand it, wouldn't allow for that
because the long-term wrapped key would remain in memory as long as the keyring
service key exists, even when only the ephemerally-wrapped key is needed.
>
> > > > I think it would be possible, but it feels like a bit of a shoehorned API. The
> > > > ioctls are a more straightforward solution.
> > >
> > > Are we going to have another set of IOCTLs for loading the encrypted
> > > keys? keys sealed by TPM?
> >
> > Those features aren't compatible with hardware-wrapped inline encryption keys,
> > so they're not really relevant here. BLKCRYPTOIMPORTKEY could support importing
> > a keyring service key as an alternative to a raw key, of course. But this would
> > just work similarly to fscrypt and dm-crypt where they just extract the payload,
> > and the keyring service key plays no further role.
>
> Yes, extracting the payload is fine. As you wrote, dm-crypt and fscrypt
> already do it in this way. But what I really don't like here is the idea
> of having two different kinds of API having pretty close functionality.
> In my opinion, all the keys should be handled via the existing keyrings
> API and then imported via the BLKCRYPTOIMPORTKEY IOCTL. This way all
> kinds of keys are handled in a similar way from user's point of view.
But in that case all the proposed new BLKCRYPTO* ioctls are still needed. Your
suggestion would just make them harder to use by requiring users to copy their
key into a keyrings service key instead of just providing it directly in the
ioctl.
>
> > > > > > Support for it will be added at some point, which will likely indeed take the
> > > > > > form of an ioctl to set a key on a block device. But that would be the case
> > > > > > even without HW-wrapped keys. And *requiring* the key to be given in a keyring
> > > > > > (instead of just in a byte array passed to the ioctl) isn't very helpful, as it
> > > > > > just makes the API harder to use. We've learned this from the fscrypt API
> > > > > > already where we actually had to move away from the keyrings service in order to
> > > > > > fix all the issues caused by it (see FS_IOC_ADD_ENCRYPTION_KEY).
> > > > > >
> > > > > > > >
> > > > > > > > > Second part is the actual block interface. Gaurav wrote about
> > > > > > > > > targeting fscrypt, but there should be no actual difference between
> > > > > > > > > crypto targets. FDE or having a single partition encrypted should
> > > > > > > > > probably work in the same way. Convert the key into blk_crypto_key
> > > > > > > > > (including the cookie for the ephemeral key), program the key into the
> > > > > > > > > slot, use the slot to en/decrypt hardware blocks.
> > > > > > > > >
> > > > > > > > > My main point is that the decision on the key type should be coming
> > > > > > > > > from the user.
> > > > > > > >
> > > > > > > > That's exactly how it works. There is a block interface for specifying an
> > > > > > > > inline encryption key along with each bio. The submitter of the bio can specify
> > > > > > > > either a standard key or a HW-wrapped key.
> > > > > > >
> > > > > > > Not in this patchset. The ICE driver decides whether it can support
> > > > > > > HW-wrapped keys or not and then fails to support other type of keys.
> > > > > > >
> > > > > >
> > > > > > Sure, that's just a matter of hardware capabilities though, right? The block
> > > > > > layer provides a way for drivers to declare which inline encryption capabilities
> > > > > > they support. They can declare they support standard keys, HW-wrapped keys,
> > > > > > both, or neither. If Qualcomm SoCs can't support both types of keys at the same
> > > > > > time, that's unfortunate, but I'm not sure what your poitnt is. The user (e.g.
> > > > > > fscrypt) still has control over whether they use the functionality that the
> > > > > > hardware provides.
> > > > >
> > > > > It's a matter of policy. Harware / firmware doesn't support using both
> > > > > kinds of keys concurrently, if I understood Gaurav's explanations
> > > > > correctly. But the user should be able to make a judgement and use
> > > > > non-hw-wrapped keys if it fits their requirements. The driver should
> > > > > not make this kind of judgement. Note, this is not an issue of your
> > > > > original patchset, but it's a driver flaw in this patchset.
> > > >
> > > > If the driver has to make a decision about which type of keys to support (due to
> > > > the hardware and firmware supporting both but not at the same time), I think
> > > > this will need to be done via a module parameter, e.g.
> > > > qcom_ice.hw_wrapped_keys=1 to support HW-wrapped keys instead of standard keys.
> > >
> > > No, the user can not set modparams on e.g. Android device. In my
> > > opinion it should be first-come-first-serve. If the user wants
> > > hw-wrapped keys (and the platform is fine with that), then further
> > > attempts to use raw keys should fail. If the user loads a raw key,
> > > further attempts to set hw-wrapped key should fail (maybe until the
> > > last raw key has been evicted from the hw, if such thing is actually
> > > supported).
> >
> > That's not going to work. Upper layers need to know what the crypto
> > capabilities are before they decide to use them. We can't randomly revoke
> > capabilities based on who happened to get there first, as a user might have
> > already checked the capabilities. Yes, the module parameter is a litle
> > annoying, but it seems to be necessary here.
>
> Hmm. This is typical to have resource-limited capabilities. So yes, the
> user checks the capabilities to identify whether the key type is
> supported at all. But then _using_ the key might fail. For example
> because all the hardware resources that are used by this key type are
> already taken.
That mustn't happen here, since finding out in the middle of an I/O request that
inline encryption isn't supported is too late. That's what the crypto
capabilities in struct blk_crypto_profile are for -- to allow users to check
what is supported before trying to use it.
>
> > It is not a problem for Android
> > because the type of encryption an Android device uses is set by the build
> > anyway, which makes it no easier to change than module parameters.
>
> If AOSP misbehaves, it doesn't mean that we should follow the pattern.
It's not "misbehaving" -- it's just an example of a system that configures the
encryption centrally, which is common. (And the reason I brought up that the
module parameter works for Android is because you claimed it wouldn't.)
Again, needing a module parameter is unfortunate but I don't see any realistic
way around it for these Qualcomm SoCs.
- Eric
next prev parent reply other threads:[~2024-06-21 21:46 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 0:50 [PATCH v5 00/15] Hardware wrapped key support for qcom ice and ufs Gaurav Kashyap
2024-06-17 0:50 ` [PATCH v5 01/15] ice, ufs, mmc: use blk_crypto_key for program_key Gaurav Kashyap
2024-06-17 0:50 ` [PATCH v5 02/15] qcom_scm: scm call for deriving a software secret Gaurav Kashyap
2024-06-17 7:33 ` Dmitry Baryshkov
2024-06-17 0:50 ` [PATCH v5 03/15] qcom_scm: scm call for create, prepare and import keys Gaurav Kashyap
2024-06-17 7:39 ` Dmitry Baryshkov
2024-06-17 0:50 ` [PATCH v5 04/15] soc: qcom: ice: add hwkm support in ice Gaurav Kashyap
2024-06-17 7:54 ` Dmitry Baryshkov
2024-06-18 22:07 ` Gaurav Kashyap (QUIC)
2024-06-18 22:16 ` Dmitry Baryshkov
2024-06-19 22:30 ` Gaurav Kashyap (QUIC)
2024-06-20 11:57 ` Dmitry Baryshkov
2024-06-21 4:47 ` Eric Biggers
2024-06-21 15:16 ` Dmitry Baryshkov
2024-06-21 15:39 ` Eric Biggers
2024-06-21 16:06 ` Dmitry Baryshkov
2024-06-21 16:31 ` Eric Biggers
2024-06-21 17:49 ` Dmitry Baryshkov
2024-06-21 18:36 ` Eric Biggers
2024-06-21 19:24 ` Dmitry Baryshkov
2024-06-21 20:14 ` Eric Biggers
2024-06-21 20:52 ` Dmitry Baryshkov
2024-06-21 21:46 ` Eric Biggers [this message]
2024-06-21 15:35 ` Gaurav Kashyap
2024-06-21 15:38 ` Gaurav Kashyap (QUIC)
2024-06-21 16:01 ` Eric Biggers
2024-06-25 4:58 ` Gaurav Kashyap (QUIC)
2024-06-25 8:21 ` neil.armstrong
2024-06-18 7:13 ` neil.armstrong
2024-06-18 22:08 ` Gaurav Kashyap (QUIC)
2024-06-19 6:16 ` Krzysztof Kozlowski
2024-06-19 22:02 ` Gaurav Kashyap (QUIC)
2024-06-20 6:51 ` Krzysztof Kozlowski
2024-06-19 7:12 ` Neil Armstrong
2024-06-19 22:03 ` Gaurav Kashyap (QUIC)
2024-06-17 0:51 ` [PATCH v5 05/15] soc: qcom: ice: support for hardware wrapped keys Gaurav Kashyap
2024-06-17 7:58 ` Dmitry Baryshkov
2024-06-17 0:51 ` [PATCH v5 06/15] soc: qcom: ice: support for generate, import and prepare key Gaurav Kashyap
2024-06-17 7:59 ` Dmitry Baryshkov
2024-06-17 0:51 ` [PATCH v5 07/15] ufs: core: support wrapped keys in ufs core Gaurav Kashyap
2024-06-17 8:01 ` Dmitry Baryshkov
2024-06-17 0:51 ` [PATCH v5 08/15] ufs: core: add support to derive software secret Gaurav Kashyap
2024-06-17 17:37 ` Konrad Dybcio
2024-06-17 0:51 ` [PATCH v5 09/15] ufs: core: add support for generate, import and prepare keys Gaurav Kashyap
2024-06-17 17:38 ` Konrad Dybcio
2024-06-17 0:51 ` [PATCH v5 10/15] ufs: host: wrapped keys support in ufs qcom Gaurav Kashyap
2024-06-17 0:51 ` [PATCH v5 11/15] ufs: host: implement derive sw secret vop " Gaurav Kashyap
2024-06-17 0:51 ` [PATCH v5 12/15] ufs: host: support for generate, import and prepare key Gaurav Kashyap
2024-06-17 0:51 ` [PATCH v5 13/15] dt-bindings: crypto: ice: document the hwkm property Gaurav Kashyap
2024-06-17 7:16 ` Krzysztof Kozlowski
2024-06-18 0:35 ` Gaurav Kashyap (QUIC)
2024-06-18 6:30 ` Krzysztof Kozlowski
2024-06-19 22:07 ` Gaurav Kashyap (QUIC)
2024-06-17 17:39 ` Konrad Dybcio
2024-06-17 0:51 ` [PATCH v5 14/15] arm64: dts: qcom: sm8650: add hwkm support to ufs ice Gaurav Kashyap
2024-06-17 8:21 ` Krzysztof Kozlowski
2024-06-17 8:28 ` neil.armstrong
2024-06-17 17:40 ` Konrad Dybcio
2024-06-17 0:51 ` [PATCH v5 15/15] arm64: dts: qcom: sm8550: " Gaurav Kashyap
2024-06-17 7:17 ` [PATCH v5 00/15] Hardware wrapped key support for qcom ice and ufs Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240621214624.GA3861295@google.com \
--to=ebiggers@kernel.org \
--cc=andersson@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=herbert@gondor.apana.org.au \
--cc=jejb@linux.ibm.com \
--cc=kernel@quicinc.com \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mani@kernel.org \
--cc=martin.petersen@oracle.com \
--cc=neil.armstrong@linaro.org \
--cc=psodagud@quicinc.com \
--cc=quic_gaurkash@quicinc.com \
--cc=quic_nguyenb@quicinc.com \
--cc=quic_omprsing@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=sonalg@quicinc.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).