From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org
Subject: Re: [PATCH 4/6] io_uring/rw: add defensive hardening for negative kbuf lengths
Date: Tue, 21 Apr 2026 13:10:59 -0400 [thread overview]
Message-ID: <87340oqlwc.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <20260421135626.581917-5-axboe@kernel.dk> (Jens Axboe's message of "Tue, 21 Apr 2026 07:51:41 -0600")
Jens Axboe <axboe@kernel.dk> writes:
> No real bug here, just being a bit defensive in ensuring that whatever
> gets passed into io_put_kbuf() is always >= 0 and not some random error
> value.
>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
> io_uring/rw.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/io_uring/rw.c b/io_uring/rw.c
> index 20654deff84d..e729e0e7657e 100644
> --- a/io_uring/rw.c
> +++ b/io_uring/rw.c
> @@ -580,7 +580,7 @@ void io_req_rw_complete(struct io_tw_req tw_req, io_tw_token_t tw)
> io_req_io_end(req);
>
> if (req->flags & (REQ_F_BUFFER_SELECTED|REQ_F_BUFFER_RING))
> - req->cqe.flags |= io_put_kbuf(req, req->cqe.res, NULL);
> + req->cqe.flags |= io_put_kbuf(req, max(req->cqe.res, 0), NULL);
>
> io_req_rw_cleanup(req, 0);
> io_req_task_complete(tw_req, tw);
> @@ -1379,7 +1379,7 @@ int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin)
> list_del(&req->iopoll_node);
> wq_list_add_tail(&req->comp_list, &ctx->submit_state.compl_reqs);
> nr_events++;
> - req->cqe.flags = io_put_kbuf(req, req->cqe.res, NULL);
> + req->cqe.flags = io_put_kbuf(req, max(req->cqe.res, 0), NULL);
> if (!io_is_uring_cmd(req))
> io_req_rw_cleanup(req, 0);
> }
Much more readable if it were rolled as an early return inside io_put_kbuf, but clearly:
Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
--
Gabriel Krisman Bertazi
next prev parent reply other threads:[~2026-04-21 17:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 13:51 [PATCHSET 0/6] Various bug fixes Jens Axboe
2026-04-21 13:51 ` [PATCH 1/6] io_uring: fix spurious fput in registered ring path Jens Axboe
2026-04-21 17:05 ` Gabriel Krisman Bertazi
2026-04-21 13:51 ` [PATCH 2/6] io_uring/rsrc: unify nospec indexing for direct descriptors Jens Axboe
2026-04-21 17:09 ` Gabriel Krisman Bertazi
2026-04-21 13:51 ` [PATCH 3/6] io_uring/rsrc: use kvfree() for the imu cache Jens Axboe
2026-04-21 13:51 ` [PATCH 4/6] io_uring/rw: add defensive hardening for negative kbuf lengths Jens Axboe
2026-04-21 17:10 ` Gabriel Krisman Bertazi [this message]
2026-04-21 13:51 ` [PATCH 5/6] io_uring/futex: ensure partial wakes are appropriately dequeued Jens Axboe
2026-04-21 17:11 ` Gabriel Krisman Bertazi
2026-04-21 13:51 ` [PATCH 6/6] io_uring/register: fix ring resizing with mixed/large SQEs/CQEs Jens Axboe
2026-04-21 17:12 ` Gabriel Krisman Bertazi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87340oqlwc.fsf@mailhost.krisman.be \
--to=krisman@suse.de \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox