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] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 22 Aug 2022 13:15:46 +0200
From:   Pavel Machek <pavel@...x.de>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        Nimish Mishra <neelam.nimish@...il.com>,
        Anirban Chakraborty <ch.anirban00727@...il.com>,
        Debdeep Mukhopadhyay <debdeep.mukhopadhyay@...il.com>,
        Jerome Forissier <jerome.forissier@...aro.org>,
        Jens Wiklander <jens.wiklander@...aro.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH 5.10 540/545] tee: add overflow check in
 register_shm_helper()

Hi!

> From: Jens Wiklander <jens.wiklander@...aro.org>
> 
> commit 573ae4f13f630d6660008f1974c0a8a29c30e18a upstream.
> 
> With special lengths supplied by user space, register_shm_helper() has
> an integer overflow when calculating the number of pages covered by a
> supplied user space memory region.
> 
> This causes internal_get_user_pages_fast() a helper function of
> pin_user_pages_fast() to do a NULL pointer dereference:

Maybe this needs fixing, but this fix adds a memory leak or two. Note
the goto err, that needs to be done.

Best regards,
								Pavel

Signed-off-by: Pavel Machek <pavel@...x.de>

> +++ b/drivers/tee/tee_shm.c
> @@ -222,6 +222,9 @@ struct tee_shm *tee_shm_register(struct
>  		goto err;
>  	}
>  
> +	if (!access_ok((void __user *)addr, length))
> +		return ERR_PTR(-EFAULT);
> +
>  	mutex_lock(&teedev->mutex);
>  	shm->id = idr_alloc(&teedev->idr, shm, 1, 0, GFP_KERNEL);
>  	mutex_unlock(&teedev->mutex);
> 


diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
index 6e662fb131d5..283fa50676a2 100644
--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -222,8 +222,10 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
 		goto err;
 	}
 
-	if (!access_ok((void __user *)addr, length))
-		return ERR_PTR(-EFAULT);
+	if (!access_ok((void __user *)addr, length)) {
+		ret = ERR_PTR(-EFAULT);
+		goto err;
+	}
 
 	mutex_lock(&teedev->mutex);
 	shm->id = idr_alloc(&teedev->idr, shm, 1, 0, GFP_KERNEL);

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ