All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Wiklander <jens.wiklander@linaro.org>
To: Etienne Carriere <etienne.carriere@linaro.org>
Cc: alexandre.jutras@nxp.com,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tee: check shm references are consistent in offset/size
Date: Mon, 7 May 2018 10:24:18 +0200	[thread overview]
Message-ID: <CAHUa44GU5zWJOLGzQa06ZJO4eYitNFd+XkXL9gRXzt7zcbAd3A@mail.gmail.com> (raw)
In-Reply-To: <1525004549-16266-1-git-send-email-etienne.carriere@linaro.org>

On Sun, Apr 29, 2018 at 2:22 PM, Etienne Carriere
<etienne.carriere@linaro.org> wrote:
> This change prevents userland from referencing TEE shared memory
> outside the area initially allocated by its owner. Prior this change an
> application could not reference or access memory it did not own but
> it could reference memory not explicitly allocated by owner but still
> allocated to the owner due to the memory allocation granule.
>
> Reported-by: Alexandre Jutras <alexandre.jutras@nxp.com>
> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
> ---
>  drivers/tee/tee_core.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
> index 0124a91..dd46b75 100644
> --- a/drivers/tee/tee_core.c
> +++ b/drivers/tee/tee_core.c
> @@ -238,6 +238,17 @@ static int params_from_user(struct tee_context *ctx, struct tee_param *params,
>                         if (IS_ERR(shm))
>                                 return PTR_ERR(shm);
>
> +                       /*
> +                        * Ensure offset + size does not overflow offset
> +                        * and does not overflow the size of the referred
> +                        * shared memory object.
> +                        */
> +                       if ((ip.a + ip.b) < ip.a ||
> +                           (ip.a + ip.b) > shm->size) {
> +                               tee_shm_put(shm);
> +                               return -EINVAL;
> +                       }
> +
>                         params[n].u.memref.shm_offs = ip.a;
>                         params[n].u.memref.size = ip.b;
>                         params[n].u.memref.shm = shm;
> --
> 1.9.1
>

Looks good to me, I'll pick this up.

Thanks,
Jens

  reply	other threads:[~2018-05-07  8:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-29 12:22 [PATCH] tee: check shm references are consistent in offset/size Etienne Carriere
2018-05-07  8:24 ` Jens Wiklander [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-04-27 13:53 Etienne Carriere
2018-04-27 15:58 ` Randy Dunlap

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=CAHUa44GU5zWJOLGzQa06ZJO4eYitNFd+XkXL9gRXzt7zcbAd3A@mail.gmail.com \
    --to=jens.wiklander@linaro.org \
    --cc=alexandre.jutras@nxp.com \
    --cc=etienne.carriere@linaro.org \
    --cc=linux-kernel@vger.kernel.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 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.