All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Yang Yingliang <yangyingliang@huawei.com>,
	linux-kernel@vger.kernel.org, io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: Re: [PATCH] io_uring: fix memleak in io_init_wq_offload()
Date: Tue, 20 Jul 2021 07:52:09 -0600	[thread overview]
Message-ID: <43a58f84-bd43-a644-bc8c-642147b354aa@kernel.dk> (raw)
In-Reply-To: <20210720083805.3030730-1-yangyingliang@huawei.com>

On 7/20/21 2:38 AM, Yang Yingliang wrote:
> I got memory leak report when doing fuzz test:
> 
> BUG: memory leak
> unreferenced object 0xffff888107310a80 (size 96):
> comm "syz-executor.6", pid 4610, jiffies 4295140240 (age 20.135s)
> hex dump (first 32 bytes):
> 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> 00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N..........
> backtrace:
> [<000000001974933b>] kmalloc include/linux/slab.h:591 [inline]
> [<000000001974933b>] kzalloc include/linux/slab.h:721 [inline]
> [<000000001974933b>] io_init_wq_offload fs/io_uring.c:7920 [inline]
> [<000000001974933b>] io_uring_alloc_task_context+0x466/0x640 fs/io_uring.c:7955
> [<0000000039d0800d>] __io_uring_add_tctx_node+0x256/0x360 fs/io_uring.c:9016
> [<000000008482e78c>] io_uring_add_tctx_node fs/io_uring.c:9052 [inline]
> [<000000008482e78c>] __do_sys_io_uring_enter fs/io_uring.c:9354 [inline]
> [<000000008482e78c>] __se_sys_io_uring_enter fs/io_uring.c:9301 [inline]
> [<000000008482e78c>] __x64_sys_io_uring_enter+0xabc/0xc20 fs/io_uring.c:9301
> [<00000000b875f18f>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
> [<00000000b875f18f>] do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80
> [<000000006b0a8484>] entry_SYSCALL_64_after_hwframe+0x44/0xae
> 
> CPU0                          CPU1
> io_uring_enter                io_uring_enter
> io_uring_add_tctx_node        io_uring_add_tctx_node
> __io_uring_add_tctx_node      __io_uring_add_tctx_node
> io_uring_alloc_task_context   io_uring_alloc_task_context
> io_init_wq_offload            io_init_wq_offload
> hash = kzalloc                hash = kzalloc
> ctx->hash_map = hash          ctx->hash_map = hash <- one of the hash is leaked
> 
> When calling io_uring_enter() in parallel, the 'hash_map' will be leaked, 
> add uring_lock to protect 'hash_map'.

Good catch! Applied, thanks.

-- 
Jens Axboe


      parent reply	other threads:[~2021-07-20 14:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-20  8:38 [PATCH] io_uring: fix memleak in io_init_wq_offload() Yang Yingliang
2021-07-20 10:16 ` Pavel Begunkov
2021-07-20 13:52 ` Jens Axboe [this message]

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=43a58f84-bd43-a644-bc8c-642147b354aa@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yangyingliang@huawei.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.