From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Igor Opaniuk <igor.opaniuk@gmail.com>
Cc: u-boot@lists.denx.de, jens.wiklander@linaro.org,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Jorge Ramirez-Ortiz <jorge@foundries.io>,
Sam Protsenko <semen.protsenko@linaro.org>,
Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH v1] tee: sandbox: check for buffer size
Date: Fri, 26 Apr 2024 08:18:20 +0300 [thread overview]
Message-ID: <Zis5HMOgbvL8rgvo@hera> (raw)
In-Reply-To: <20240421204839.2129998-1-igor.opaniuk@gmail.com>
On Sun, Apr 21, 2024 at 10:48:39PM +0200, Igor Opaniuk wrote:
> Add additional check for buffer size when reading out persistent
> storage value and provide back actual value size.
>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@gmail.com>
> ---
>
> drivers/tee/sandbox.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c
> index 8ad7c09efdd..86b16a3bb8d 100644
> --- a/drivers/tee/sandbox.c
> +++ b/drivers/tee/sandbox.c
> @@ -174,7 +174,7 @@ static u32 ta_avb_invoke_func(struct udevice *dev, u32 func, uint num_params,
> uint slot;
> u64 val;
> char *value;
> - u32 value_sz;
> + u32 value_sz, tmp_sz;
>
> switch (func) {
> case TA_AVB_CMD_READ_ROLLBACK_INDEX:
> @@ -267,8 +267,12 @@ static u32 ta_avb_invoke_func(struct udevice *dev, u32 func, uint num_params,
> if (!ep)
> return TEE_ERROR_ITEM_NOT_FOUND;
>
> - value_sz = strlen(ep->data) + 1;
> - memcpy(value, ep->data, value_sz);
> + tmp_sz = strlen(ep->data) + 1;
> + if (value_sz < tmp_sz)
> + return TEE_ERROR_SHORT_BUFFER;
> +
> + memcpy(value, ep->data, tmp_sz);
> + params[1].u.memref.size = tmp_sz;
>
> return TEE_SUCCESS;
> case TA_AVB_CMD_WRITE_PERSIST_VALUE:
> --
> 2.34.1
>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
prev parent reply other threads:[~2024-04-26 5:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-21 20:48 [PATCH v1] tee: sandbox: check for buffer size Igor Opaniuk
2024-04-22 14:52 ` Oleksandr Suvorov
2024-04-26 5:18 ` Ilias Apalodimas [this message]
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=Zis5HMOgbvL8rgvo@hera \
--to=ilias.apalodimas@linaro.org \
--cc=igor.opaniuk@gmail.com \
--cc=jens.wiklander@linaro.org \
--cc=jorge@foundries.io \
--cc=semen.protsenko@linaro.org \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.