From: Thomas Huth <thuth@redhat.com>
To: Gan Qixin <ganqixin@huawei.com>,
qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
kuhn.chenqun@huawei.com, zhang.zhanghailiang@huawei.com,
Euler Robot <euler.robot@huawei.com>
Subject: Re: [PATCH v2] qtest/libqtest: fix heap-buffer-overflow in qtest_cb_for_every_machine()
Date: Wed, 6 Jan 2021 13:24:22 +0100 [thread overview]
Message-ID: <1a9e2ca1-bec8-5b5f-aad6-cb4b21b44000@redhat.com> (raw)
In-Reply-To: <20210106050625.518041-1-ganqixin@huawei.com>
On 06/01/2021 06.06, Gan Qixin wrote:
> When the length of mname is less than 5, memcpy("xenfv", mname, 5) will cause
> heap buffer overflow. Therefore, use strncmp to avoid this problem.
>
> The asan showed stack:
>
> ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000f2f4 at
> pc 0x7f65d8cc2225 bp 0x7ffe93cc5a60 sp 0x7ffe93cc5208 READ of size 5 at
> 0x60200000f2f4 thread T0
> #0 0x7f65d8cc2224 in memcmp (/lib64/libasan.so.5+0xdf224)
> #1 0x5632c20be95b in qtest_cb_for_every_machine tests/qtest/libqtest.c:1282
> #2 0x5632c20b7995 in main tests/qtest/test-hmp.c:160
> #3 0x7f65d88fed42 in __libc_start_main (/lib64/libc.so.6+0x26d42)
> #4 0x5632c20b72cd in _start (build/tests/qtest/test-hmp+0x542cd)
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Gan Qixin <ganqixin@huawei.com>
> ---
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Laurent Vivier <lvivier@redhat.com>
>
> v2:
> Changes suggested by Thomas Huth:
> Replace memcmp(..., 5) with strncmp(..., 5).
> ---
> tests/qtest/libqtest.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks, queued now to my qtest-next branch:
https://gitlab.com/huth/qemu/-/commits/qtest-next/
Thomas
prev parent reply other threads:[~2021-01-06 12:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 5:06 [PATCH v2] qtest/libqtest: fix heap-buffer-overflow in qtest_cb_for_every_machine() Gan Qixin
2021-01-06 11:29 ` Laurent Vivier
2021-01-06 12:24 ` Thomas Huth [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=1a9e2ca1-bec8-5b5f-aad6-cb4b21b44000@redhat.com \
--to=thuth@redhat.com \
--cc=euler.robot@huawei.com \
--cc=ganqixin@huawei.com \
--cc=kuhn.chenqun@huawei.com \
--cc=lvivier@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=zhang.zhanghailiang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).