io_uring: ensure open/openat2 name is cleaned on cancelation
authorJens Axboe <axboe@kernel.dk>
Thu, 24 Sep 2020 20:55:54 +0000 (14:55 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 25 Sep 2020 13:41:46 +0000 (07:41 -0600)
If we cancel these requests, we'll leak the memory associated with the
filename. Add them to the table of ops that need cleaning, if
REQ_F_NEED_CLEANUP is set.

Cc: stable@vger.kernel.org
Fixes: e62753e4e292 ("io_uring: call statx directly")
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index e6004b9..0ab16df 100644 (file)
@@ -5671,6 +5671,11 @@ static void __io_clean_op(struct io_kiocb *req)
                        io_put_file(req, req->splice.file_in,
                                    (req->splice.flags & SPLICE_F_FD_IN_FIXED));
                        break;
+               case IORING_OP_OPENAT:
+               case IORING_OP_OPENAT2:
+                       if (req->open.filename)
+                               putname(req->open.filename);
+                       break;
                }
                req->flags &= ~REQ_F_NEED_CLEANUP;
        }