Re: [PATCH v2 05/11] fhandle: reflow get_path_anchor()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 24, 2025 at 11:16:39AM +0200, Jan Kara wrote:
> On Tue 24-06-25 10:29:08, Christian Brauner wrote:
> > Switch to a more common coding style.
> > 
> > Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
> > ---
> >  fs/fhandle.c | 16 ++++++++++------
> >  1 file changed, 10 insertions(+), 6 deletions(-)
> > 
> > diff --git a/fs/fhandle.c b/fs/fhandle.c
> > index d8d32208c621..22edced83e4c 100644
> > --- a/fs/fhandle.c
> > +++ b/fs/fhandle.c
> > @@ -170,18 +170,22 @@ SYSCALL_DEFINE5(name_to_handle_at, int, dfd, const char __user *, name,
> >  
> >  static int get_path_anchor(int fd, struct path *root)
> >  {
> > +	if (fd >= 0) {
> > +		CLASS(fd, f)(fd);
> > +		if (fd_empty(f))
> > +			return -EBADF;
> > +		*root = fd_file(f)->f_path;
> > +		path_get(root);
> > +		return 0;
> > +	}
> > +
> >  	if (fd == AT_FDCWD) {
> >  		struct fs_struct *fs = current->fs;
> >  		spin_lock(&fs->lock);
> >  		*root = fs->pwd;
> >  		path_get(root);
> >  		spin_unlock(&fs->lock);
> > -	} else {
> > -		CLASS(fd, f)(fd);
> > -		if (fd_empty(f))
> > -			return -EBADF;
> > -		*root = fd_file(f)->f_path;
> > -		path_get(root);
> > +		return 0;
> >  	}
> 
> This actually introduces a regression that when userspace passes invalid fd
> < 0, we'd be returning 0 whereas previously we were returning -EBADF. I
> think the return below should be switched to -EBADF to fix that.

Whoops. Thanks!




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux