lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 28 Dec 2017 22:10:28 +0100
From:   Jens Wiklander <jens.wiklander@...aro.org>
To:     Colin King <colin.king@...onical.com>
Cc:     kernel-janitors@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] tee: shm: don't put_page on null shm->pages

On Fri, Dec 22, 2017 at 6:51 PM, Colin King <colin.king@...onical.com> wrote:
> From: Colin Ian King <colin.king@...onical.com>
>
> In the case that shm->pages fails to allocate, the current exit
> error path will try to put_page on a null shm->pages and cause
> a null pointer dereference when accessing shm->pages[n]. Fix this
> by only performing the put_page and kfree on shm->pages if it
> is not null.
>
> Detected by CoverityScan, CID#1463283 ("Dereference after null check")
>
> Fixes: 033ddf12bcf5 ("tee: add register user memory")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
>  drivers/tee/tee_shm.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
> index 13b4de1157c7..6890c8aaef8c 100644
> --- a/drivers/tee/tee_shm.c
> +++ b/drivers/tee/tee_shm.c
> @@ -335,9 +335,11 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
>                         idr_remove(&teedev->idr, shm->id);
>                         mutex_unlock(&teedev->mutex);
>                 }
> -               for (n = 0; n < shm->num_pages; n++)
> -                       put_page(shm->pages[n]);
> -               kfree(shm->pages);
> +               if (shm->pages) {
> +                       for (n = 0; n < shm->num_pages; n++)
> +                               put_page(shm->pages[n]);
> +                       kfree(shm->pages);
> +               }
>         }
>         kfree(shm);
>         teedev_ctx_put(ctx);
> --
> 2.14.1
>

Looks good. Thanks.

/Jens

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ