On 6/3/21 6:18 AM, Dmitry Kadashev wrote: > IORING_OP_MKNODAT behaves like mknodat(2) and takes the same flags and > arguments. > > Suggested-by: Christian Brauner <christian.brauner@xxxxxxxxxx> > Link: https://lore.kernel.org/io-uring/20210514145259.wtl4xcsp52woi6ab@wittgenstein/ > Signed-off-by: Dmitry Kadashev <dkadashev@xxxxxxxxx> > --- > fs/internal.h | 2 ++ > fs/io_uring.c | 56 +++++++++++++++++++++++++++++++++++ > fs/namei.c | 2 +- > include/uapi/linux/io_uring.h | 2 ++ > 4 files changed, 61 insertions(+), 1 deletion(-) > > diff --git a/fs/internal.h b/fs/internal.h > index 15a7d210cc67..c6fb9974006f 100644 [...] > static bool io_disarm_next(struct io_kiocb *req); > @@ -3687,6 +3697,44 @@ static int io_linkat(struct io_kiocb *req, int issue_flags) > io_req_complete(req, ret); > return 0; > } > +static int io_mknodat_prep(struct io_kiocb *req, > + const struct io_uring_sqe *sqe) > +{ > + struct io_mknod *mkn = &req->mknod; > + const char __user *fname; > + > + if (unlikely(req->flags & REQ_F_FIXED_FILE)) > + return -EBADF; IOPOLL won't support it, and the check is missing. Probably for other opcodes as well. if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) return -EINVAL; > + > + mkn->dfd = READ_ONCE(sqe->fd); > + mkn->mode = READ_ONCE(sqe->len); > + fname = u64_to_user_ptr(READ_ONCE(sqe->addr)); > + mkn->dev = READ_ONCE(sqe->mknod_dev); > + > + mkn->filename = getname(fname); > + if (IS_ERR(mkn->filename)) > + return PTR_ERR(mkn->filename); > + > + req->flags |= REQ_F_NEED_CLEANUP; > + return 0; > +} -- Pavel Begunkov