From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@st.com>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-kernel@vger.kernel.org>
Cc: Hulk Robot <hulkci@huawei.com>
Subject: Re: [PATCH 1/2] hwtracing: stm: fix vfree() nonexistent vm_area
Date: Mon, 20 May 2019 17:19:49 +0800 [thread overview]
Message-ID: <57ffbd01-2624-e7b4-bd27-d93cd49fbc9f@huawei.com> (raw)
In-Reply-To: <20190520091315.27898-1-wangkefeng.wang@huawei.com>
sorry, send wrong version, please ignore.
On 2019/5/20 17:13, Kefeng Wang wrote:
> If device_add() in stm_register_device() fails, stm_device_release()
> is called to free stm, free stm again on err_device path will trigger
> following warning,
>
> Trying to vfree() nonexistent vm area (0000000054b5e7bc)
> WARNING: CPU: 0 PID: 6004 at mm/vmalloc.c:1595 __vunmap+0x72/0x480 mm/vmalloc.c:1594
> Kernel panic - not syncing: panic_on_warn set ...
> CPU: 0 PID: 6004 Comm: syz-executor.0 Tainted: G C 5.1.0+ #28
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
> Call Trace:
> __vfree+0x2a/0x80 mm/vmalloc.c:1658
> _vfree+0x49/0x70 mm/vmalloc.c:1688
> stm_register_device+0x295/0x330 [stm_core]
> dummy_stm_init+0xfe/0x1e0 [dummy_stm]
> do_one_initcall+0xb9/0x3b5 init/main.c:914
> do_init_module+0xe0/0x330 kernel/module.c:3468
> load_module+0x38eb/0x4270 kernel/module.c:3819
> __do_sys_finit_module+0x162/0x190 kernel/module.c:3909
> do_syscall_64+0x72/0x2a0 arch/x86/entry/common.c:298
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> Only free stm once if device_add() fails to fix it.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> drivers/hwtracing/stm/core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
> index e55b902560de..7b2ab7b2cc4d 100644
> --- a/drivers/hwtracing/stm/core.c
> +++ b/drivers/hwtracing/stm/core.c
> @@ -864,6 +864,7 @@ static void stm_device_release(struct device *dev)
> struct stm_device *stm = to_stm_device(dev);
>
> vfree(stm);
> + stm->data->stm = NULL;
> }
>
> int stm_register_device(struct device *parent, struct stm_data *stm_data,
> @@ -933,7 +934,8 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
> /* matches device_initialize() above */
> put_device(&stm->dev);
> err_free:
> - vfree(stm);
> + if (stm->data->stm)
> + vfree(stm);
>
> return err;
> }
prev parent reply other threads:[~2019-05-20 9:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-20 9:13 Kefeng Wang
2019-05-20 9:13 ` [PATCH 2/2] hwtracing: stm: fix double-free in stm_source_register_device() Kefeng Wang
2019-05-20 9:20 ` Kefeng Wang
2019-05-20 9:19 ` Kefeng Wang [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=57ffbd01-2624-e7b4-bd27-d93cd49fbc9f@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexandre.torgue@st.com \
--cc=gregkh@linuxfoundation.org \
--cc=hulkci@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome