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]
Message-ID: <20130220123159.GD9138@mwanda>
Date:	Wed, 20 Feb 2013 15:31:59 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	Shankar Brahadeeswaran <shankoo77@...il.com>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-kernel@...r.kernel.org, devel@...verdev.osuosl.org,
	Hugh Dickins <hughd@...gle.com>,
	Konstantin Khlebnikov <khlebnikov@...nvz.org>,
	Cruz Julian Bishop <cruzjbishop@...il.com>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 1/1] staging: android: ashmem: get_name,set_name not to
 hold ashmem_mutex

On Wed, Feb 20, 2013 at 05:53:59PM +0530, Shankar Brahadeeswaran wrote:
>  static int set_name(struct ashmem_area *asma, void __user *name)
>  {
>  	int ret = 0;
> -
> -	mutex_lock(&ashmem_mutex);
> +	char local_name[ASHMEM_NAME_LEN];
>  
>  	/* cannot change an existing mapping's name */
>  	if (unlikely(asma->file)) {
> @@ -423,9 +422,22 @@ static int set_name(struct ashmem_area *asma, void __user *name)
>  		goto out;

You're not holding the lock here so you can return directly.
Otherwise it's a double unlock.

>  	}
>  
> -	if (unlikely(copy_from_user(asma->name + ASHMEM_NAME_PREFIX_LEN,
> -				    name, ASHMEM_NAME_LEN)))
> +	/*
> +	 * Holding the ashmem_mutex while doing a copy_from_user might cause
> +	 * an data abourt which would try to access mmap_sem. If another
> +	 * thread has invoked ashmem_mmap then it will be holding the
> +	 * semaphore and will be waiting for ashmem_mutex, there by leading to
> +	 * deadlock. We'll release the mutex  and take the name to a local
> +	 * variable that does not need protection and later copy the local
> +	 * variable to the structure member with lock held.
> +	 */
> +	if (unlikely(copy_from_user(local_name, name, ASHMEM_NAME_LEN))) {
>  		ret = -EFAULT;
> +		return ret;

		return -EFAULT;

These weren't there in the original, only when you redid it at my
request.  :/  Sorry for that.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ