[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACMJSetM_JQ+1bTEszc4EtaUwb2iKkbg3WFWVTsXa14KD_VKCA@mail.gmail.com>
Date: Tue, 6 Feb 2024 12:59:36 +0100
From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
To: Gaurav Kashyap <quic_gaurkash@...cinc.com>
Cc: linux-arm-msm@...r.kernel.org, linux-scsi@...r.kernel.org,
andersson@...nel.org, ebiggers@...gle.com, neil.armstrong@...aro.org,
srinivas.kandagatla@...aro.org, krzysztof.kozlowski+dt@...aro.org,
conor+dt@...nel.org, robh+dt@...nel.org, linux-kernel@...r.kernel.org,
linux-mmc@...r.kernel.org, kernel@...cinc.com, linux-crypto@...r.kernel.org,
devicetree@...r.kernel.org, quic_omprsing@...cinc.com,
quic_nguyenb@...cinc.com, konrad.dybcio@...aro.org, ulf.hansson@...aro.org,
jejb@...ux.ibm.com, martin.petersen@...cle.com, mani@...nel.org,
davem@...emloft.net, herbert@...dor.apana.org.au
Subject: Re: [PATCH v4 03/15] qcom_scm: scm call for create, prepare and
import keys
On Sun, 28 Jan 2024 at 00:26, Gaurav Kashyap <quic_gaurkash@...cinc.com> wrote:
>
> Storage encryption has two IOCTLs for creating, importing
> and preparing keys for encryption. For wrapped keys, these
> IOCTLs need to interface with Qualcomm's Trustzone, which
> require these SCM calls.
>
> generate_key: This is used to generate and return a longterm
> wrapped key. Trustzone achieves this by generating
> a key and then wrapping it using hwkm, returning
> a wrapped keyblob.
> import_key: The functionality is similar to generate, but here,
> a raw key is imported into hwkm and a longterm wrapped
> keyblob is returned.
> prepare_key: The longterm wrapped key from import or generate
> is made further secure by rewrapping it with a per-boot
> ephemeral wrapped key before installing it to the linux
> kernel for programming to ICE.
>
> Signed-off-by: Gaurav Kashyap <quic_gaurkash@...cinc.com>
> Tested-by: Neil Armstrong <neil.armstrong@...aro.org>
> ---
> drivers/firmware/qcom/qcom_scm.c | 182 +++++++++++++++++++++++++
> drivers/firmware/qcom/qcom_scm.h | 3 +
> include/linux/firmware/qcom/qcom_scm.h | 5 +
> 3 files changed, 190 insertions(+)
>
> diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
> index 4882f8a36453..20dbab765c8e 100644
> --- a/drivers/firmware/qcom/qcom_scm.c
> +++ b/drivers/firmware/qcom/qcom_scm.c
> @@ -1285,6 +1285,188 @@ int qcom_scm_derive_sw_secret(const u8 *wkey, size_t wkey_size,
> }
> EXPORT_SYMBOL_GPL(qcom_scm_derive_sw_secret);
>
> +/**
> + * qcom_scm_generate_ice_key() - Generate a wrapped key for encryption.
> + * @lt_key: the wrapped key returned after key generation
> + * @lt_key_size: size of the wrapped key to be returned.
> + *
> + * Qualcomm wrapped keys need to be generated in a trusted environment.
> + * A generate key IOCTL call is used to achieve this. These are longterm
> + * in nature as they need to be generated and wrapped only once per
> + * requirement.
> + *
> + * Adds support for the create key IOCTL to interface
> + * with the secure environment to generate and return a wrapped key..
> + *
> + * Return: longterm key size on success; -errno on failure.
> + */
> +int qcom_scm_generate_ice_key(u8 *lt_key, size_t lt_key_size)
> +{
> + struct qcom_scm_desc desc = {
> + .svc = QCOM_SCM_SVC_ES,
> + .cmd = QCOM_SCM_ES_GENERATE_ICE_KEY,
> + .arginfo = QCOM_SCM_ARGS(2, QCOM_SCM_RW, QCOM_SCM_VAL),
> + .args[1] = lt_key_size,
> + .owner = ARM_SMCCC_OWNER_SIP,
> + };
> +
> + void *lt_key_buf;
> + int ret;
> +
> + lt_key_buf = qcom_tzmem_alloc(__scm->mempool, lt_key_size, GFP_KERNEL);
Please use __free(qcom_tzmem) everywhere in this series. You can take
a look at the calls I converted in the series adding this allocator.
It's really useful - especially if the buffer is surely freed within
the same scope.
Bart
[snip]
Powered by blists - more mailing lists