From: Daniel Yang <danielyangkang@gmail.com>
To: Jens Axboe <axboe@kernel.dk>,
Pavel Begunkov <asml.silence@gmail.com>,
io-uring@vger.kernel.org (open list:IO_URING),
linux-kernel@vger.kernel.org (open list)
Cc: Daniel Yang <danielyangkang@gmail.com>,
syzbot+05c0f12a4d43d656817e@syzkaller.appspotmail.com
Subject: [PATCH] io_uring/rsrc: fix null ptr dereference in io_sqe_buffer_register
Date: Sun, 3 Nov 2024 19:51:05 -0800 [thread overview]
Message-ID: <20241104035105.192960-1-danielyangkang@gmail.com> (raw)
The call stack io_sqe_buffer_register -> io_buffer_account_pin ->
headpage_already_acct results in a null ptr dereference in the for loop.
There is no guarantee that ctx->buf_table.nodes[i] is an allocated node
so add a check if null before dereferencing.
Signed-off-by: Daniel Yang <danielyangkang@gmail.com>
Reported-by: syzbot+05c0f12a4d43d656817e@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=05c0f12a4d43d656817e
Fixes: 661768085e99 ("io_uring/rsrc: get rid of the empty node and dummy_ubuf")
---
io_uring/rsrc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index af60d9f59..e2edb752a 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -581,6 +581,8 @@ static bool headpage_already_acct(struct io_ring_ctx *ctx, struct page **pages,
/* check previously registered pages */
for (i = 0; i < ctx->buf_table.nr; i++) {
struct io_rsrc_node *node = ctx->buf_table.nodes[i];
+ if (!node)
+ continue;
struct io_mapped_ubuf *imu = node->buf;
for (j = 0; j < imu->nr_bvecs; j++) {
--
2.39.2
next reply other threads:[~2024-11-04 3:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 3:51 Daniel Yang [this message]
2024-11-04 3:58 ` [PATCH] io_uring/rsrc: fix null ptr dereference in io_sqe_buffer_register Jens Axboe
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=20241104035105.192960-1-danielyangkang@gmail.com \
--to=danielyangkang@gmail.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+05c0f12a4d43d656817e@syzkaller.appspotmail.com \
/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