Pull file descriptor fix from Al Viro: "Fix for breakage in #work.fd this window" * tag 'pull-work.fd-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: fix the breakage in close_fd_get_file() calling conventions change
Unified · Split
| @@ -1886,6 +1886,8 @@ static void binder_deferred_fd_close(int fd) · 1885 unmodified lines | |||
| 1886 | init_task_work(&twcb->twork, binder_do_fd_close); | 1886 | init_task_work(&twcb->twork, binder_do_fd_close); |
| 1887 | twcb->file = close_fd_get_file(fd); | 1887 | twcb->file = close_fd_get_file(fd); |
| 1888 | if (twcb->file) { | 1888 | if (twcb->file) { |
| 1889 | // pin it until binder_do_fd_close(); see comments there | ||
| 1890 | get_file(twcb->file); | ||
| 1889 | filp_close(twcb->file, current->files); | 1891 | filp_close(twcb->file, current->files); |
| 1890 | task_work_add(current, &twcb->twork, TWA_RESUME); | 1892 | task_work_add(current, &twcb->twork, TWA_RESUME); |
| 1891 | } else { | 1893 | } else { |
| @@ -800,8 +800,7 @@ struct file *__close_fd_get_file(unsigned int fd) · 799 unmodified lines | |||
| 800 | 800 | ||
| 801 | /* | 801 | /* |
| 802 | * variant of close_fd that gets a ref on the file for later fput. | 802 | * variant of close_fd that gets a ref on the file for later fput. |
| 803 | * The caller must ensure that filp_close() called on the file, and then | 803 | * The caller must ensure that filp_close() called on the file. |
| 804 | * an fput(). | ||
| 805 | */ | 804 | */ |
| 806 | struct file *close_fd_get_file(unsigned int fd) | 805 | struct file *close_fd_get_file(unsigned int fd) |
| 807 | { | 806 | { |
| @@ -6010,7 +6010,7 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags) · 6009 unmodified lines | |||
| 6010 | struct files_struct *files = current->files; | 6010 | struct files_struct *files = current->files; |
| 6011 | struct io_close *close = &req->close; | 6011 | struct io_close *close = &req->close; |
| 6012 | struct fdtable *fdt; | 6012 | struct fdtable *fdt; |
| 6013 | struct file *file = NULL; | 6013 | struct file *file; |
| 6014 | int ret = -EBADF; | 6014 | int ret = -EBADF; |
| 6015 | 6015 | ||
| 6016 | if (req->close.file_slot) { | 6016 | if (req->close.file_slot) { |
| @@ -6029,7 +6029,6 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags) · 12 unmodified lines | |||
| 6029 | lockdep_is_held(&files->file_lock)); | 6029 | lockdep_is_held(&files->file_lock)); |
| 6030 | if (!file || file->f_op == &io_uring_fops) { | 6030 | if (!file || file->f_op == &io_uring_fops) { |
| 6031 | spin_unlock(&files->file_lock); | 6031 | spin_unlock(&files->file_lock); |
| 6032 | file = NULL; | ||
| 6033 | goto err; | 6032 | goto err; |
| 6034 | } | 6033 | } |
| 6035 | 6034 | ||
| @@ -6049,8 +6048,6 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags) · 13 unmodified lines | |||
| 6049 | err: | 6048 | err: |
| 6050 | if (ret < 0) | 6049 | if (ret < 0) |
| 6051 | req_set_fail(req); | 6050 | req_set_fail(req); |
| 6052 | if (file) | ||
| 6053 | fput(file); | ||
| 6054 | __io_req_complete(req, issue_flags, ret, 0); | 6051 | __io_req_complete(req, issue_flags, ret, 0); |
| 6055 | return 0; | 6052 | return 0; |
| 6056 | } | 6053 | } |