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: <20241202155832.uoc4h4xazyocmqot@quack3>
Date: Mon, 2 Dec 2024 16:58:32 +0100
From: Jan Kara <jack@...e.cz>
To: Christian Brauner <brauner@...nel.org>
Cc: Erin Shepherd <erin.shepherd@....eu>,
	Amir Goldstein <amir73il@...il.com>,
	Jeff Layton <jlayton@...nel.org>,
	Alexander Viro <viro@...iv.linux.org.uk>, Jan Kara <jack@...e.cz>,
	Chuck Lever <chuck.lever@...cle.com>, linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-nfs@...r.kernel.org
Subject: Re: [PATCH RFC 2/6] fhandle: simplify error handling

On Fri 29-11-24 14:38:01, Christian Brauner wrote:
> Rely on our cleanup infrastructure.
> 
> Signed-off-by: Christian Brauner <brauner@...nel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza

> ---
>  fs/fhandle.c | 39 +++++++++++++++++----------------------
>  1 file changed, 17 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/fhandle.c b/fs/fhandle.c
> index ec9145047dfc9d25e109e72d210987bbf6b36a20..c00d88fb14e16654b5cbbb71760c0478eac20384 100644
> --- a/fs/fhandle.c
> +++ b/fs/fhandle.c
> @@ -261,19 +261,20 @@ static int do_handle_to_path(struct file_handle *handle, struct path *path,
>  {
>  	int handle_dwords;
>  	struct vfsmount *mnt = ctx->root.mnt;
> +	struct dentry *dentry;
>  
>  	/* change the handle size to multiple of sizeof(u32) */
>  	handle_dwords = handle->handle_bytes >> 2;
> -	path->dentry = exportfs_decode_fh_raw(mnt,
> -					  (struct fid *)handle->f_handle,
> -					  handle_dwords, handle->handle_type,
> -					  ctx->fh_flags,
> -					  vfs_dentry_acceptable, ctx);
> -	if (IS_ERR_OR_NULL(path->dentry)) {
> -		if (path->dentry == ERR_PTR(-ENOMEM))
> +	dentry = exportfs_decode_fh_raw(mnt, (struct fid *)handle->f_handle,
> +					handle_dwords, handle->handle_type,
> +					ctx->fh_flags, vfs_dentry_acceptable,
> +					ctx);
> +	if (IS_ERR_OR_NULL(dentry)) {
> +		if (dentry == ERR_PTR(-ENOMEM))
>  			return -ENOMEM;
>  		return -ESTALE;
>  	}
> +	path->dentry = dentry;
>  	path->mnt = mntget(mnt);
>  	return 0;
>  }
> @@ -398,29 +399,23 @@ static long do_handle_open(int mountdirfd, struct file_handle __user *ufh,
>  			   int open_flag)
>  {
>  	long retval = 0;
> -	struct path path;
> +	struct path path __free(path_put) = {};
>  	struct file *file;
> -	int fd;
>  
>  	retval = handle_to_path(mountdirfd, ufh, &path, open_flag);
>  	if (retval)
>  		return retval;
>  
> -	fd = get_unused_fd_flags(open_flag);
> -	if (fd < 0) {
> -		path_put(&path);
> +	CLASS(get_unused_fd, fd)(O_CLOEXEC);
> +	if (fd < 0)
>  		return fd;
> -	}
> +
>  	file = file_open_root(&path, "", open_flag, 0);
> -	if (IS_ERR(file)) {
> -		put_unused_fd(fd);
> -		retval =  PTR_ERR(file);
> -	} else {
> -		retval = fd;
> -		fd_install(fd, file);
> -	}
> -	path_put(&path);
> -	return retval;
> +	if (IS_ERR(file))
> +		return PTR_ERR(file);
> +
> +	fd_install(fd, file);
> +	return take_fd(fd);
>  }
>  
>  /**
> 
> -- 
> 2.45.2
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ