From: Eric Blake <eblake@redhat.com>
To: zhanghailiang <zhang.zhanghailiang@huawei.com>, qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com, armbru@redhat.com,
luonengjun@huawei.com, peter.huangpeng@huawei.com,
qemu-stable@nongnu.org, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qga: Fix possible freed memory accessing
Date: Thu, 18 Sep 2014 06:53:10 -0600 [thread overview]
Message-ID: <541AD5B6.6080809@redhat.com> (raw)
In-Reply-To: <541AD33A.1040309@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 1072 bytes --]
On 09/18/2014 06:42 AM, zhanghailiang wrote:
> On 2014/9/18 20:17, Eric Blake wrote:
>> On 09/17/2014 09:33 PM, zhanghailiang wrote:
>>> If readdir_r fails, error_setg_errno will reference the freed
>>> pointer *dirpath*.
>>>
>>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>>> ---
>>> qga/commands-posix.c | 10 ++++++----
>>> 1 file changed, 6 insertions(+), 4 deletions(-)
>>
>>> for (;;) {
>>> if (readdir_r(dir, &entry, &result) != 0) {
>>
>> Eww. We're using readdir_r? That's an inherently broken interface,
>> which can risk buffer overflow. readdir should be preferred.
>>
>> http://austingroupbugs.net/view.php?id=696
>>
>
> Yes, it is! Should i fix it in this patch together?;)
Switching to readdir would be welcome, and would probably be enough of a
rewrite that it would also fix the use-after-free without trying to
break it into two patches. You're welcome to try that as a v2.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
prev parent reply other threads:[~2014-09-18 12:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 3:33 [Qemu-devel] [PATCH] qga: Fix possible freed memory accessing zhanghailiang
2014-09-18 7:00 ` Markus Armbruster
2014-09-18 12:17 ` Eric Blake
2014-09-18 12:42 ` zhanghailiang
2014-09-18 12:53 ` Eric Blake [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=541AD5B6.6080809@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=luonengjun@huawei.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=peter.huangpeng@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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 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.