]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
io_uring: explicit sqe padding for ioctl commands
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 7 Jul 2022 14:00:38 +0000 (15:00 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 7 Jul 2022 23:33:01 +0000 (17:33 -0600)
32 bit sqe->cmd_op is an union with 64 bit values. It's always a good
idea to do padding explicitly. Also zero check it in prep, so it can be
used in the future if needed without compatibility concerns.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/e6b95a05e970af79000435166185e85b196b2ba2.1657202417.git.asml.silence@gmail.com
[axboe: turn bitwise OR into logical variant]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c
include/uapi/linux/io_uring.h

index 0d491ad15b66ad92eb12b480331b32e841675281..cddc0e8490af8574e2174af8284e5b2ec8c7fb1e 100644 (file)
@@ -5066,7 +5066,7 @@ static int io_uring_cmd_prep(struct io_kiocb *req,
 {
        struct io_uring_cmd *ioucmd = &req->uring_cmd;
 
-       if (sqe->rw_flags)
+       if (sqe->rw_flags || sqe->__pad1)
                return -EINVAL;
        ioucmd->cmd = sqe->cmd;
        ioucmd->cmd_op = READ_ONCE(sqe->cmd_op);
index f10b59d6693e310b7024431b20a807dead16497e..0ad3da28d2fce870982d6a175de4086695bffbe0 100644 (file)
@@ -22,7 +22,10 @@ struct io_uring_sqe {
        union {
                __u64   off;    /* offset into file */
                __u64   addr2;
-               __u32   cmd_op;
+               struct {
+                       __u32   cmd_op;
+                       __u32   __pad1;
+               };
        };
        union {
                __u64   addr;   /* pointer to buffer or iovecs */