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:	Thu, 23 Sep 2010 16:19:19 -0400
From:	Valerie Aurora <vaurora@...hat.com>
To:	Miklos Szeredi <miklos@...redi.hu>
Cc:	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
	neilb@...e.de, viro@...iv.linux.org.uk, stable@...nel.org
Subject: Re: [PATCH 5/7 v3] vfs: fix possible use after free in finish_open()

On Mon, Sep 20, 2010 at 08:04:09PM +0200, Miklos Szeredi wrote:
> From: Miklos Szeredi <mszeredi@...e.cz>
> 
> If open(O_TRUNC) is called and the actual open fails, then nd->path
> will be released by nameidata_to_filp().  If this races with an
> unmount then mnt_drop_write() can Oops.
> 
> Fix by acquiring a ref to nd->path and releasing after
> mnt_drop_write().
> 
> Signed-off-by: Miklos Szeredi <mszeredi@...e.cz>
> CC: stable@...nel.org
> ---
>  fs/namei.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> Index: linux-2.6/fs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/namei.c	2010-09-20 13:32:35.000000000 +0200
> +++ linux-2.6/fs/namei.c	2010-09-20 13:33:14.000000000 +0200
> @@ -1559,6 +1559,11 @@ static struct file *finish_open(struct n
>  			mnt_drop_write(nd->path.mnt);
>  		goto exit;
>  	}
> +	if (will_truncate) {
> +		/* nameidata_to_filp() puts nd->path! */
> +		path_get(&nd->path);
> +	}
> +
>  	filp = nameidata_to_filp(nd);
>  	if (!IS_ERR(filp)) {
>  		error = ima_file_check(filp, acc_mode);
> @@ -1581,8 +1586,10 @@ static struct file *finish_open(struct n
>  	 * because the filp has had a write taken
>  	 * on its behalf.
>  	 */
> -	if (will_truncate)
> +	if (will_truncate) {
>  		mnt_drop_write(nd->path.mnt);
> +		path_put(&nd->path);
> +	}
>  	return filp;
>  
>  exit:
> 

Nice catch!

Reviewed-by: Valerie Aurora <vaurora@...hat.com>

-VAL
--
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