Message ID | 5301f9fd-70e3-4156-bfe2-864adda9b71d@kernel.dk (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | io_uring/uring_cmd: use cached cmd_op in io_uring_cmd_sock() | expand |
On Thu, Jan 23, 2025 at 1:32 AM Jens Axboe <axboe@kernel.dk> wrote: > io_uring_cmd_sock() does a read of cmd->sqe->cmd_op, which may look > like it's the userspace shared SQE, but it's a copy at this point. > Use cmd->cmd_op rather than dip into the allocated SQE copy - it's > both simpler and faster and leaves less room for confusion. > > Link: https://lore.kernel.org/r/20250121-uring-sockcmd-fix-v1-1-add742802a29@google.com > Signed-off-by: Jens Axboe <axboe@kernel.dk> > > --- > > diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c > index fc94c465a985..3993c9339ac7 100644 > --- a/io_uring/uring_cmd.c > +++ b/io_uring/uring_cmd.c > @@ -350,7 +350,7 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > if (!prot || !prot->ioctl) > return -EOPNOTSUPP; > > - switch (cmd->sqe->cmd_op) { > + switch (cmd->cmd_op) { Ah, yeah, this does look better than the READ_ONCE() I suggested.
diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index fc94c465a985..3993c9339ac7 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -350,7 +350,7 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) if (!prot || !prot->ioctl) return -EOPNOTSUPP; - switch (cmd->sqe->cmd_op) { + switch (cmd->cmd_op) { case SOCKET_URING_OP_SIOCINQ: ret = prot->ioctl(sk, SIOCINQ, &arg); if (ret)
io_uring_cmd_sock() does a read of cmd->sqe->cmd_op, which may look like it's the userspace shared SQE, but it's a copy at this point. Use cmd->cmd_op rather than dip into the allocated SQE copy - it's both simpler and faster and leaves less room for confusion. Link: https://lore.kernel.org/r/20250121-uring-sockcmd-fix-v1-1-add742802a29@google.com Signed-off-by: Jens Axboe <axboe@kernel.dk> ---