Re: [PATCH v2] fs: always return zero on success from replace_fd()

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

 



On Mon, Aug 04, 2025 at 02:33:13PM +0200, Christian Brauner wrote:

> +       guard(spinlock)(&files->file_lock);
>         err = expand_files(files, fd);
>         if (unlikely(err < 0))
> -               goto out_unlock;
> -       return do_dup2(files, file, fd, flags);
> +               return err;
> +       err = do_dup2(files, file, fd, flags);
> +       if (err < 0)
> +               return err;
> 
> -out_unlock:
> -       spin_unlock(&files->file_lock);
> -       return err;
> +       return 0;
>  }

NAK.  This is broken - do_dup2() drops ->file_lock.  And that's why I
loathe the guard() - it's too easy to get confused *and* assume that
it will DTRT, no need to check carefully.




[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