From: Jens Axboe <axboe@kernel.dk>
To: chase xd <sl1589472800@gmail.com>,
Pavel Begunkov <asml.silence@gmail.com>,
io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [io-uring] general protection fault in io_register_clone_buffers
Date: Thu, 12 Dec 2024 07:58:39 -0700 [thread overview]
Message-ID: <85c4b3a6-559a-4f1d-bf2d-ec2db876dec7@kernel.dk> (raw)
In-Reply-To: <CADZouDRcO6QORhUUHGRBQvZ_q8nip0S+Mn4Hb61W8zi_OfmSag@mail.gmail.com>
On 12/12/24 3:06 AM, chase xd wrote:
> Syzkaller hit 'general protection fault in io_register_clone_buffers' bug.
>
> Oops: general protection fault, probably for non-canonical address
> 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN NOPTI
> KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
> CPU: 5 UID: 0 PID: 12910 Comm: syz-executor169 Not tainted
> 6.12.0-rc4-00089-g7eb75ce75271-dirty #7
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
> RIP: 0010:io_clone_buffers io_uring/rsrc.c:1039 [inline]
> RIP: 0010:io_register_clone_buffers+0xbb1/0xf40 io_uring/rsrc.c:1076
> Code: 48 63 c3 41 89 dd 4c 8d 3c c6 4c 89 fa 48 c1 ea 03 42 80 3c 22
> 00 0f 85 61 02 00 00 49 8b 17 48 8d 7a 10 48 89 f9 48 c1 e9 03 <42> 80
> 3c 21 00 0f 85 62 02 00 00 48 8b 72 10 4c 89 f7 e8 b8 93 ff
> RSP: 0018:ffffc90011047bd8 EFLAGS: 00010212
> RAX: 0000000000000001 RBX: 0000000000000001 RCX: 0000000000000002
> RDX: 0000000000000000 RSI: ffff888017acfec0 RDI: 0000000000000010
> RBP: ffffc90011047d28 R08: 0000000000000000 R09: fffffbfff1dbb731
> R10: 0000000000000002 R11: 0000000000000000 R12: dffffc0000000000
> R13: 0000000000000001 R14: ffff888021760000 R15: ffff888017acfec8
> FS: 00007fcbf80f4640(0000) GS:ffff88823bf00000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007fcbf806e658 CR3: 000000002420a000 CR4: 0000000000750ef0
> PKRU: 55555554
> Call Trace:
> <TASK>
> __io_uring_register+0x922/0x2290 io_uring/register.c:804
> __do_sys_io_uring_register io_uring/register.c:907 [inline]
> __se_sys_io_uring_register io_uring/register.c:884 [inline]
> __x64_sys_io_uring_register+0x178/0x2b0 io_uring/register.c:884
> do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> do_syscall_64+0xcb/0x250 arch/x86/entry/common.c:83
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
> RIP: 0033:0x7fcbf815322d
> Code: c3 e8 77 24 00 00 0f 1f 80 00 00 00 00 f3 0f 1e fa 48 89 f8 48
> 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d
> 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
> RSP: 002b:00007fcbf80f41a8 EFLAGS: 00000246 ORIG_RAX: 00000000000001ab
> RAX: ffffffffffffffda RBX: 00007fcbf81f5088 RCX: 00007fcbf815322d
> RDX: 0000000020000600 RSI: 000000000000001e RDI: 0000000000000004
> RBP: 00007fcbf81f5080 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000000c90
> R13: 0000000000000003 R14: 00007fcbf811a630 R15: 00007fcbf80d4000
> </TASK>
> Modules linked in:
> ---[ end trace 0000000000000000 ]---
> RIP: 0010:io_clone_buffers io_uring/rsrc.c:1039 [inline]
> RIP: 0010:io_register_clone_buffers+0xbb1/0xf40 io_uring/rsrc.c:1076
I can't run these crazy syzbot reproducers, I do wish they'd be dwindled
down to the bare minimum rather than have tons of unrelated bits in
there. That said, can you check with this patch?
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index adaae8630932..077f84684c18 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -1036,8 +1036,10 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
out_put_free:
i = data.nr;
while (i--) {
- io_buffer_unmap(src_ctx, data.nodes[i]);
- kfree(data.nodes[i]);
+ if (data.nodes[i]) {
+ io_buffer_unmap(src_ctx, data.nodes[i]);
+ kfree(data.nodes[i]);
+ }
}
out_unlock:
io_rsrc_data_free(ctx, &data);
--
Jens Axboe
next prev parent reply other threads:[~2024-12-12 14:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 10:06 [io-uring] general protection fault in io_register_clone_buffers chase xd
2024-12-12 14:58 ` Jens Axboe [this message]
2024-12-13 9:39 ` chase xd
2024-12-13 14:09 ` 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=85c4b3a6-559a-4f1d-bf2d-ec2db876dec7@kernel.dk \
--to=axboe@kernel.dk \
--cc=asml.silence@gmail.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sl1589472800@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.