History

Merge tag 'pull-work.fd-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

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

Linus Torvalds committed 4 years ago

Commit 6684cf42 parents 815b196 40a19263 files · +4 −6Browse files

Unified · Split

3 files
  1. drivers/android/binder.c +2 −0
  2. fs/file.c +1 −2
  3. fs/io_uring.c +1 −4
drivers/android/binder.c+2−0
@@ -1886,6 +1886,8 @@ static void binder_deferred_fd_close(int fd) · 1885 unmodified lines
18861886 init_task_work(&twcb->twork, binder_do_fd_close);
18871887 twcb->file = close_fd_get_file(fd);
18881888 if (twcb->file) {
1889+ // pin it until binder_do_fd_close(); see comments there
1890+ get_file(twcb->file);
18891891 filp_close(twcb->file, current->files);
18901892 task_work_add(current, &twcb->twork, TWA_RESUME);
18911893 } else {
fs/file.c+1−2
@@ -800,8 +800,7 @@ struct file *__close_fd_get_file(unsigned int fd) · 799 unmodified lines
800800
801801 /*
802802 * 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
804− * an fput().
803+ * The caller must ensure that filp_close() called on the file.
805804 */
806805 struct file *close_fd_get_file(unsigned int fd)
807806 {
fs/io_uring.c+1−4
@@ -6010,7 +6010,7 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags) · 6009 unmodified lines
60106010 struct files_struct *files = current->files;
60116011 struct io_close *close = &req->close;
60126012 struct fdtable *fdt;
6013− struct file *file = NULL;
6013+ struct file *file;
60146014 int ret = -EBADF;
60156015
60166016 if (req->close.file_slot) {
@@ -6029,7 +6029,6 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags) · 12 unmodified lines
60296029 lockdep_is_held(&files->file_lock));
60306030 if (!file || file->f_op == &io_uring_fops) {
60316031 spin_unlock(&files->file_lock);
6032− file = NULL;
60336032 goto err;
60346033 }
60356034
@@ -6049,8 +6048,6 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags) · 13 unmodified lines
60496048 err:
60506049 if (ret < 0)
60516050 req_set_fail(req);
6052− if (file)
6053− fput(file);
60546051 __io_req_complete(req, issue_flags, ret, 0);
60556052 return 0;
60566053 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t