diff mbox series

[6/6] io_uring: use rcu_dereference in io_close

Message ID 20220518084005.3255380-7-hch@lst.de (mailing list archive)
State New
Headers show
Series [1/6] io_uring: use a rwf_t for io_rw.flags | expand

Commit Message

Christoph Hellwig May 18, 2022, 8:40 a.m. UTC
Accessing the file table needs a rcu_dereference_protected().

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/io_uring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/io_uring.c b/fs/io_uring.c
index c9596d551bd67..2b848a8dfc46c 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5984,7 +5984,8 @@  static int io_close(struct io_kiocb *req, unsigned int issue_flags)
 		spin_unlock(&files->file_lock);
 		goto err;
 	}
-	file = fdt->fd[close->fd];
+	file = rcu_dereference_protected(fdt->fd[close->fd],
+			lockdep_is_held(&files->file_lock));
 	if (!file || file->f_op == &io_uring_fops) {
 		spin_unlock(&files->file_lock);
 		file = NULL;