Re: [PATCH] file: always lock position

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

 



On Tue, 25 Jul 2023 at 13:41, Jens Axboe <axboe@xxxxxxxxx> wrote:
>
> Right, but what if the original app closes the file descriptor? Now you
> have the io_uring file table still holding a reference to it, but it'd
> just be 1. Which is enough to keep it alive, but you can still have
> multiple IOs inflight against this file.

Note that fdget_pos() fundamentally only works on file descriptors
that are there - it's literally looking them up in the file table as
it goes along. And it looks at the count of the file description as it
is looked up. So that refcount is guaranteed to exist.

If the file has been closed, fdget_pos() will just fail because it
doesn't find it.

And if it's then closed *afterwards*, that's fine and doesn't affect
anything, because the locking has been done and we saved away the
status bit as FDPUT_POS_UNLOCK, so the code knows to unlock even if
the file descriptor in the meantime has turned back to having just a
single refcount.

     Linus



[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