Commit 73363c2
committed
io_uring: use fget/fput consistently
Normally within a syscall it's fine to use fdget/fdput for grabbing a
file from the file table, and it's fine within io_uring as well. We do
that via io_uring_enter(2), io_uring_register(2), and then also for
cancel which is invoked from the latter. io_uring cannot close its own
file descriptors as that is explicitly rejected, and for the cancel
side of things, the file itself is just used as a lookup cookie.
However, it is more prudent to ensure that full references are always
grabbed. For anything threaded, either explicitly in the application
itself or through use of the io-wq worker threads, this is what happens
anyway. Generalize it and use fget/fput throughout.
Also see the below link for more details.
Link: https://lore.kernel.org/io-uring/CAG48ez1htVSO3TqmrF8QcX2WFuYTRM-VZ_N10i-VZgbtg=NNqw@mail.gmail.com/
Suggested-by: Jann Horn <jannh@google.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>1 parent 5cf4f52 commit 73363c2
2 files changed
Lines changed: 24 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | | - | |
| 276 | + | |
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
299 | | - | |
| 298 | + | |
| 299 | + | |
300 | 300 | | |
301 | | - | |
| 301 | + | |
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | | - | |
| 351 | + | |
| 352 | + | |
352 | 353 | | |
353 | 354 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3652 | 3652 | | |
3653 | 3653 | | |
3654 | 3654 | | |
3655 | | - | |
| 3655 | + | |
3656 | 3656 | | |
3657 | 3657 | | |
3658 | 3658 | | |
| |||
3670 | 3670 | | |
3671 | 3671 | | |
3672 | 3672 | | |
3673 | | - | |
3674 | | - | |
3675 | | - | |
| 3673 | + | |
| 3674 | + | |
3676 | 3675 | | |
3677 | 3676 | | |
3678 | | - | |
3679 | | - | |
| 3677 | + | |
| 3678 | + | |
3680 | 3679 | | |
3681 | 3680 | | |
3682 | | - | |
| 3681 | + | |
3683 | 3682 | | |
3684 | 3683 | | |
3685 | 3684 | | |
3686 | | - | |
| 3685 | + | |
3687 | 3686 | | |
3688 | 3687 | | |
3689 | 3688 | | |
| |||
3777 | 3776 | | |
3778 | 3777 | | |
3779 | 3778 | | |
3780 | | - | |
| 3779 | + | |
| 3780 | + | |
3781 | 3781 | | |
3782 | 3782 | | |
3783 | 3783 | | |
| |||
4618 | 4618 | | |
4619 | 4619 | | |
4620 | 4620 | | |
4621 | | - | |
| 4621 | + | |
4622 | 4622 | | |
4623 | 4623 | | |
4624 | 4624 | | |
| |||
4637 | 4637 | | |
4638 | 4638 | | |
4639 | 4639 | | |
4640 | | - | |
4641 | | - | |
4642 | | - | |
| 4640 | + | |
| 4641 | + | |
4643 | 4642 | | |
4644 | 4643 | | |
4645 | | - | |
4646 | | - | |
| 4644 | + | |
| 4645 | + | |
4647 | 4646 | | |
4648 | 4647 | | |
4649 | | - | |
| 4648 | + | |
4650 | 4649 | | |
4651 | 4650 | | |
4652 | 4651 | | |
4653 | | - | |
| 4652 | + | |
4654 | 4653 | | |
4655 | 4654 | | |
4656 | 4655 | | |
4657 | 4656 | | |
4658 | 4657 | | |
4659 | 4658 | | |
4660 | | - | |
| 4659 | + | |
| 4660 | + | |
4661 | 4661 | | |
4662 | 4662 | | |
4663 | 4663 | | |
| |||
0 commit comments