Merge tag 'for-5.18/io_uring-2022-04-01' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / fs / io_uring.c
index 3d0dbcd..a8413f0 100644 (file)
@@ -79,7 +79,6 @@
 #include <linux/task_work.h>
 #include <linux/pagemap.h>
 #include <linux/io_uring.h>
-#include <linux/tracehook.h>
 #include <linux/audit.h>
 #include <linux/security.h>
 
@@ -676,7 +675,7 @@ struct io_statx {
        int                             dfd;
        unsigned int                    mask;
        unsigned int                    flags;
-       const char __user               *filename;
+       struct filename                 *filename;
        struct statx __user             *buffer;
 };
 
@@ -2780,9 +2779,11 @@ static inline unsigned int io_sqring_entries(struct io_ring_ctx *ctx)
 
 static inline bool io_run_task_work(void)
 {
-       if (test_thread_flag(TIF_NOTIFY_SIGNAL) || current->task_works) {
+       if (test_thread_flag(TIF_NOTIFY_SIGNAL) || task_work_pending(current)) {
                __set_current_state(TASK_RUNNING);
-               tracehook_notify_signal();
+               clear_notify_signal();
+               if (task_work_pending(current))
+                       task_work_run();
                return true;
        }
 
@@ -3975,7 +3976,6 @@ static int io_write_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
        if (unlikely(!(req->file->f_mode & FMODE_WRITE)))
                return -EBADF;
-       req->rw.kiocb.ki_hint = ki_hint_validate(file_write_hint(req->file));
        return io_prep_rw(req, sqe);
 }
 
@@ -5040,6 +5040,8 @@ static int io_fadvise(struct io_kiocb *req, unsigned int issue_flags)
 
 static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
+       const char __user *path;
+
        if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
                return -EINVAL;
        if (sqe->ioprio || sqe->buf_index || sqe->splice_fd_in)
@@ -5049,10 +5051,22 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 
        req->statx.dfd = READ_ONCE(sqe->fd);
        req->statx.mask = READ_ONCE(sqe->len);
-       req->statx.filename = u64_to_user_ptr(READ_ONCE(sqe->addr));
+       path = u64_to_user_ptr(READ_ONCE(sqe->addr));
        req->statx.buffer = u64_to_user_ptr(READ_ONCE(sqe->addr2));
        req->statx.flags = READ_ONCE(sqe->statx_flags);
 
+       req->statx.filename = getname_flags(path,
+                                       getname_statx_lookup_flags(req->statx.flags),
+                                       NULL);
+
+       if (IS_ERR(req->statx.filename)) {
+               int ret = PTR_ERR(req->statx.filename);
+
+               req->statx.filename = NULL;
+               return ret;
+       }
+
+       req->flags |= REQ_F_NEED_CLEANUP;
        return 0;
 }
 
@@ -7193,6 +7207,10 @@ static void io_clean_op(struct io_kiocb *req)
                        putname(req->hardlink.oldpath);
                        putname(req->hardlink.newpath);
                        break;
+               case IORING_OP_STATX:
+                       if (req->statx.filename)
+                               putname(req->statx.filename);
+                       break;
                }
        }
        if ((req->flags & REQ_F_POLLED) && req->apoll) {
@@ -8103,7 +8121,7 @@ static int io_sq_thread(void *data)
                }
 
                prepare_to_wait(&sqd->wait, &wait, TASK_INTERRUPTIBLE);
-               if (!io_sqd_events_pending(sqd) && !current->task_works) {
+               if (!io_sqd_events_pending(sqd) && !task_work_pending(current)) {
                        bool needs_sched = true;
 
                        list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {
@@ -11166,7 +11184,7 @@ static __cold void __io_uring_show_fdinfo(struct io_ring_ctx *ctx,
 
                hlist_for_each_entry(req, list, hash_node)
                        seq_printf(m, "  op=%d, task_works=%d\n", req->opcode,
-                                       req->task->task_works != NULL);
+                                       task_work_pending(req->task));
        }
 
        seq_puts(m, "CqOverflowList:\n");