mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
io_uring/cmd: don't expose entire cmd async data
io_uring needs private bits in cmd's ->async_data, and they should never be exposed to drivers as it'd certainly be abused. Leave struct io_uring_cmd_data for the drivers but wrap it into a structure. It's a prep patch and doesn't do anything useful yet. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/20250319061251.21452-3-sidong.yang@furiosa.ai Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
575e7b0629
commit
5f14404bfa
@@ -19,7 +19,8 @@
|
||||
static void io_req_uring_cleanup(struct io_kiocb *req, unsigned int issue_flags)
|
||||
{
|
||||
struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd);
|
||||
struct io_uring_cmd_data *cache = req->async_data;
|
||||
struct io_async_cmd *ac = req->async_data;
|
||||
struct io_uring_cmd_data *cache = &ac->data;
|
||||
|
||||
if (cache->op_data) {
|
||||
kfree(cache->op_data);
|
||||
@@ -169,12 +170,15 @@ static int io_uring_cmd_prep_setup(struct io_kiocb *req,
|
||||
const struct io_uring_sqe *sqe)
|
||||
{
|
||||
struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd);
|
||||
struct io_uring_cmd_data *cache;
|
||||
struct io_async_cmd *ac;
|
||||
|
||||
cache = io_uring_alloc_async_data(&req->ctx->cmd_cache, req);
|
||||
if (!cache)
|
||||
/* see io_uring_cmd_get_async_data() */
|
||||
BUILD_BUG_ON(offsetof(struct io_async_cmd, data) != 0);
|
||||
|
||||
ac = io_uring_alloc_async_data(&req->ctx->cmd_cache, req);
|
||||
if (!ac)
|
||||
return -ENOMEM;
|
||||
cache->op_data = NULL;
|
||||
ac->data.op_data = NULL;
|
||||
|
||||
/*
|
||||
* Unconditionally cache the SQE for now - this is only needed for
|
||||
@@ -183,8 +187,8 @@ static int io_uring_cmd_prep_setup(struct io_kiocb *req,
|
||||
* that it doesn't read in per-op data, play it safe and ensure that
|
||||
* any SQE data is stable beyond prep. This can later get relaxed.
|
||||
*/
|
||||
memcpy(cache->sqes, sqe, uring_sqe_size(req->ctx));
|
||||
ioucmd->sqe = cache->sqes;
|
||||
memcpy(ac->data.sqes, sqe, uring_sqe_size(req->ctx));
|
||||
ioucmd->sqe = ac->data.sqes;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user