[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aB0MxkdKVLso4jZD@kernel.org>
Date: Thu, 8 May 2025 22:57:58 +0300
From: Jarkko Sakkinen <jarkko@...nel.org>
To: Qunqin Zhao <zhaoqunqin@...ngson.cn>
Cc: Stefano Garzarella <sgarzare@...hat.com>, lee@...nel.org,
herbert@...dor.apana.org.au, davem@...emloft.net, peterhuewe@....de,
linux-kernel@...r.kernel.org, loongarch@...ts.linux.dev,
linux-crypto@...r.kernel.org, jgg@...pe.ca,
linux-integrity@...r.kernel.org, pmenzel@...gen.mpg.de,
Yinggang Gu <guyinggang@...ngson.cn>,
Huacai Chen <chenhuacai@...ngson.cn>
Subject: Re: [PATCH v9 4/5] tpm: Add a driver for Loongson TPM device
On Wed, May 07, 2025 at 09:33:32AM +0800, Qunqin Zhao wrote:
>
> 在 2025/5/6 下午10:13, Stefano Garzarella 写道:
> > On Tue, May 06, 2025 at 11:19:46AM +0800, Qunqin Zhao wrote:
> > > Loongson Security Engine supports random number generation, hash,
> > > symmetric encryption and asymmetric encryption. Based on these
> > > encryption functions, TPM2 have been implemented in the Loongson
> > > Security Engine firmware. This driver is responsible for copying data
> > > into the memory visible to the firmware and receiving data from the
> > > firmware.
> > >
> > > Co-developed-by: Yinggang Gu <guyinggang@...ngson.cn>
> > > Signed-off-by: Yinggang Gu <guyinggang@...ngson.cn>
> > > Signed-off-by: Qunqin Zhao <zhaoqunqin@...ngson.cn>
> > > Reviewed-by: Huacai Chen <chenhuacai@...ngson.cn>
> > > Reviewed-by: Jarkko Sakkinen <jarkko@...nel.org>
> > > ---
> > > v9: "tpm_loongson_driver" --> "tpm_loongson"
> > > "depends on CRYPTO_DEV_LOONGSON_SE" --> "depends on MFD_LOONGSON_SE"
> > >
> ...
> > > +static int tpm_loongson_recv(struct tpm_chip *chip, u8 *buf, size_t
> > > count)
> > > +{
> > > + struct loongson_se_engine *tpm_engine =
> > > dev_get_drvdata(&chip->dev);
> > > + struct tpm_loongson_cmd *cmd_ret = tpm_engine->command_ret;
> > > +
> > > + memcpy(buf, tpm_engine->data_buffer, cmd_ret->data_len);
> >
> > Should we limit the memcpy to `count`?
> >
> > I mean, can happen that `count` is less than `cmd_ret->data_len`?
>
> Hi, Stefan, thanks for your comment.
>
> Firmware ensures "cmd_ret->data_len" will be less than TPM_BUFSIZE, so this
> would never happen.
It still must have check-and-fail, as we don't live in a belief system
:-) It helps to mitigate collateral damage of possible firmware bugs
(and thus -EIO is the appropriate error code).
>
> BR, Qunqin.
>
> >
> > Thanks,
> > Stefano
>
BR, Jarkko
Powered by blists - more mailing lists