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]
Message-ID: <20070927185537.GA521@infradead.org>
Date:	Thu, 27 Sep 2007 19:55:37 +0100
From:	Christoph Hellwig <hch@...radead.org>
To:	Dave Hansen <haveblue@...ibm.com>
Cc:	linux-kernel@...r.kernel.org, miklos@...redi.hu, hch@...radead.org
Subject: Re: [RFC][PATCH 5/5] make open_namei() return a filp

On Thu, Sep 27, 2007 at 11:52:15AM -0700, Dave Hansen wrote:
> If open_namei() succeeds, there is potentially a mnt_want_write()
> that needs to get balanced.  If the caller doesn't create a
> 'struct file' and eventually __fput() it, or manually drop the
> write count on an error, we have a bug.
> 
> Forcing open_namei() to return a filp fixes this.  Any caller
> getting a 'struct file' back must consider that filp instantiated
> and fput() it normally.  The callers no longer have to worry about
> ever manually releasing a mnt write count.

> diff -puN fs/open.c~make-open_namei-return-a-filp fs/open.c
> --- lxc/fs/open.c~make-open_namei-return-a-filp	2007-09-27 11:51:34.000000000 -0700
> +++ lxc-dave/fs/open.c	2007-09-27 11:51:34.000000000 -0700
> @@ -846,11 +846,7 @@ static struct file *do_filp_open(int dfd
>  	int error;
>  	struct nameidata nd;
>  
> -	error = open_namei(dfd, filename, flags, mode, &nd);
> -	if (!error)
> -		return nameidata_to_filp(&nd, flags);
> -
> -	return ERR_PTR(error);
> +	return open_namei(dfd, filename, flags, mode, &nd);

Error is unused now, and it's also rather silly to allocate the
nd here when it's only used inside open_namei.  So I'd suggest
killing do_filp_open, and maybe filp_open aswell while you're at
it.
-
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