]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
io_uring: statx/openat/openat2 don't support fixed files
authorJens Axboe <axboe@kernel.dk>
Fri, 7 Feb 2020 04:31:40 +0000 (21:31 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 8 Feb 2020 20:06:33 +0000 (13:06 -0700)
All of these opcodes take a directory file descriptor. We can't easily
support fixed files for these operations, and the use case for that
probably isn't all that clear (or sensible) anyway.

Disable IOSQE_FIXED_FILE for these operations.

Reported-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index fcb4536a3c8ca7154dee1aedd021435f9798b22a..d0384682206275b751f9e18c380af7b8b53d097a 100644 (file)
@@ -2516,6 +2516,8 @@ static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 
        if (sqe->ioprio || sqe->buf_index)
                return -EINVAL;
+       if (sqe->flags & IOSQE_FIXED_FILE)
+               return -EBADF;
 
        req->open.dfd = READ_ONCE(sqe->fd);
        req->open.how.mode = READ_ONCE(sqe->len);
@@ -2541,6 +2543,8 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 
        if (sqe->ioprio || sqe->buf_index)
                return -EINVAL;
+       if (sqe->flags & IOSQE_FIXED_FILE)
+               return -EBADF;
 
        req->open.dfd = READ_ONCE(sqe->fd);
        fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
@@ -2736,6 +2740,8 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 
        if (sqe->ioprio || sqe->buf_index)
                return -EINVAL;
+       if (sqe->flags & IOSQE_FIXED_FILE)
+               return -EBADF;
 
        req->open.dfd = READ_ONCE(sqe->fd);
        req->open.mask = READ_ONCE(sqe->len);
@@ -2809,7 +2815,7 @@ static int io_close_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
            sqe->rw_flags || sqe->buf_index)
                return -EINVAL;
        if (sqe->flags & IOSQE_FIXED_FILE)
-               return -EINVAL;
+               return -EBADF;
 
        req->close.fd = READ_ONCE(sqe->fd);
        if (req->file->f_op == &io_uring_fops ||