* [PATCH] io_uring: Fix memory leak in io_sqe_buffers_register()
@ 2021-04-30 8:25 qiang.zhang
2021-04-30 12:18 ` Pavel Begunkov
2021-04-30 12:44 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: qiang.zhang @ 2021-04-30 8:25 UTC (permalink / raw)
To: axboe, io-uring; +Cc: linux-kernel
From: Zqiang <[email protected]>
unreferenced object 0xffff8881123bf0a0 (size 32):
comm "syz-executor557", pid 8384, jiffies 4294946143 (age 12.360s)
backtrace:
[<ffffffff81469b71>] kmalloc_node include/linux/slab.h:579 [inline]
[<ffffffff81469b71>] kvmalloc_node+0x61/0xf0 mm/util.c:587
[<ffffffff815f0b3f>] kvmalloc include/linux/mm.h:795 [inline]
[<ffffffff815f0b3f>] kvmalloc_array include/linux/mm.h:813 [inline]
[<ffffffff815f0b3f>] kvcalloc include/linux/mm.h:818 [inline]
[<ffffffff815f0b3f>] io_rsrc_data_alloc+0x4f/0xc0 fs/io_uring.c:7164
[<ffffffff815f26d8>] io_sqe_buffers_register+0x98/0x3d0 fs/io_uring.c:8383
[<ffffffff815f84a7>] __io_uring_register+0xf67/0x18c0 fs/io_uring.c:9986
[<ffffffff81609222>] __do_sys_io_uring_register fs/io_uring.c:10091 [inline]
[<ffffffff81609222>] __se_sys_io_uring_register fs/io_uring.c:10071 [inline]
[<ffffffff81609222>] __x64_sys_io_uring_register+0x112/0x230 fs/io_uring.c:10071
[<ffffffff842f616a>] do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
[<ffffffff84400068>] entry_SYSCALL_64_after_hwframe+0x44/0xae
Fix data->tags memory leak, through io_rsrc_data_free() to release
data memory space.
Reported-by: [email protected]
Signed-off-by: Zqiang <[email protected]>
---
fs/io_uring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index a880edb90d0c..7a2e83bc005d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8140,7 +8140,7 @@ static void __io_sqe_buffers_unregister(struct io_ring_ctx *ctx)
for (i = 0; i < ctx->nr_user_bufs; i++)
io_buffer_unmap(ctx, &ctx->user_bufs[i]);
kfree(ctx->user_bufs);
- kfree(ctx->buf_data);
+ io_rsrc_data_free(ctx->buf_data);
ctx->user_bufs = NULL;
ctx->buf_data = NULL;
ctx->nr_user_bufs = 0;
@@ -8400,7 +8400,7 @@ static int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,
return -ENOMEM;
ret = io_buffers_map_alloc(ctx, nr_args);
if (ret) {
- kfree(data);
+ io_rsrc_data_free(data);
return ret;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring: Fix memory leak in io_sqe_buffers_register()
2021-04-30 8:25 [PATCH] io_uring: Fix memory leak in io_sqe_buffers_register() qiang.zhang
@ 2021-04-30 12:18 ` Pavel Begunkov
2021-04-30 12:44 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2021-04-30 12:18 UTC (permalink / raw)
To: qiang.zhang, axboe, io-uring; +Cc: linux-kernel
On 4/30/21 9:25 AM, [email protected] wrote:
> From: Zqiang <[email protected]>
>
> unreferenced object 0xffff8881123bf0a0 (size 32):
> comm "syz-executor557", pid 8384, jiffies 4294946143 (age 12.360s)
> backtrace:
> [<ffffffff81469b71>] kmalloc_node include/linux/slab.h:579 [inline]
> [<ffffffff81469b71>] kvmalloc_node+0x61/0xf0 mm/util.c:587
> [<ffffffff815f0b3f>] kvmalloc include/linux/mm.h:795 [inline]
> [<ffffffff815f0b3f>] kvmalloc_array include/linux/mm.h:813 [inline]
> [<ffffffff815f0b3f>] kvcalloc include/linux/mm.h:818 [inline]
> [<ffffffff815f0b3f>] io_rsrc_data_alloc+0x4f/0xc0 fs/io_uring.c:7164
> [<ffffffff815f26d8>] io_sqe_buffers_register+0x98/0x3d0 fs/io_uring.c:8383
> [<ffffffff815f84a7>] __io_uring_register+0xf67/0x18c0 fs/io_uring.c:9986
> [<ffffffff81609222>] __do_sys_io_uring_register fs/io_uring.c:10091 [inline]
> [<ffffffff81609222>] __se_sys_io_uring_register fs/io_uring.c:10071 [inline]
> [<ffffffff81609222>] __x64_sys_io_uring_register+0x112/0x230 fs/io_uring.c:10071
> [<ffffffff842f616a>] do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
> [<ffffffff84400068>] entry_SYSCALL_64_after_hwframe+0x44/0xae
>
> Fix data->tags memory leak, through io_rsrc_data_free() to release
> data memory space.
My bad, I've added io_rsrc_data_free() specifically to use it with
buffers. The patch looks good, thanks
>
> Reported-by: [email protected]
> Signed-off-by: Zqiang <[email protected]>
> ---
> fs/io_uring.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index a880edb90d0c..7a2e83bc005d 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -8140,7 +8140,7 @@ static void __io_sqe_buffers_unregister(struct io_ring_ctx *ctx)
> for (i = 0; i < ctx->nr_user_bufs; i++)
> io_buffer_unmap(ctx, &ctx->user_bufs[i]);
> kfree(ctx->user_bufs);
> - kfree(ctx->buf_data);
> + io_rsrc_data_free(ctx->buf_data);
> ctx->user_bufs = NULL;
> ctx->buf_data = NULL;
> ctx->nr_user_bufs = 0;
> @@ -8400,7 +8400,7 @@ static int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,
> return -ENOMEM;
> ret = io_buffers_map_alloc(ctx, nr_args);
> if (ret) {
> - kfree(data);
> + io_rsrc_data_free(data);
> return ret;
> }
>
>
--
Pavel Begunkov
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring: Fix memory leak in io_sqe_buffers_register()
2021-04-30 8:25 [PATCH] io_uring: Fix memory leak in io_sqe_buffers_register() qiang.zhang
2021-04-30 12:18 ` Pavel Begunkov
@ 2021-04-30 12:44 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-04-30 12:44 UTC (permalink / raw)
To: qiang.zhang, io-uring; +Cc: linux-kernel
On 4/30/21 2:25 AM, [email protected] wrote:
> From: Zqiang <[email protected]>
>
> unreferenced object 0xffff8881123bf0a0 (size 32):
> comm "syz-executor557", pid 8384, jiffies 4294946143 (age 12.360s)
> backtrace:
> [<ffffffff81469b71>] kmalloc_node include/linux/slab.h:579 [inline]
> [<ffffffff81469b71>] kvmalloc_node+0x61/0xf0 mm/util.c:587
> [<ffffffff815f0b3f>] kvmalloc include/linux/mm.h:795 [inline]
> [<ffffffff815f0b3f>] kvmalloc_array include/linux/mm.h:813 [inline]
> [<ffffffff815f0b3f>] kvcalloc include/linux/mm.h:818 [inline]
> [<ffffffff815f0b3f>] io_rsrc_data_alloc+0x4f/0xc0 fs/io_uring.c:7164
> [<ffffffff815f26d8>] io_sqe_buffers_register+0x98/0x3d0 fs/io_uring.c:8383
> [<ffffffff815f84a7>] __io_uring_register+0xf67/0x18c0 fs/io_uring.c:9986
> [<ffffffff81609222>] __do_sys_io_uring_register fs/io_uring.c:10091 [inline]
> [<ffffffff81609222>] __se_sys_io_uring_register fs/io_uring.c:10071 [inline]
> [<ffffffff81609222>] __x64_sys_io_uring_register+0x112/0x230 fs/io_uring.c:10071
> [<ffffffff842f616a>] do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
> [<ffffffff84400068>] entry_SYSCALL_64_after_hwframe+0x44/0xae
>
> Fix data->tags memory leak, through io_rsrc_data_free() to release
> data memory space.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-30 12:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-30 8:25 [PATCH] io_uring: Fix memory leak in io_sqe_buffers_register() qiang.zhang
2021-04-30 12:18 ` Pavel Begunkov
2021-04-30 12:44 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox