From: Paolo Bonzini <pbonzini@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Yang Zhong" <yang.zhong@intel.com>,
qemu-devel@nongnu.org
Cc: anthony.xu@intel.com
Subject: Re: [Qemu-devel] [PATCH] memory: reduce heap Rss size around 3M
Date: Thu, 9 Mar 2017 17:34:24 +0100 [thread overview]
Message-ID: <0c8f4fb6-89c4-84a5-6bbe-8fa849f17764@redhat.com> (raw)
In-Reply-To: <eb781f48-a5cf-4790-f0e8-4ef083c1e1a4@amsat.org>
On 08/03/2017 12:17, Philippe Mathieu-Daudé wrote:
> On 03/08/2017 12:11 PM, Yang Zhong wrote:
>> Since cpu-memory and memory have same address space,one malloced
>> memory is enough. This patch will skip memory malloc for memory
>> address space,which will reduce around 3M physical memory in heap.
>>
>> Signed-off-by: Yang Zhong <yang.zhong@intel.com>
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
>> ---
>> memory.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/memory.c b/memory.c
>> index 284894b..799ca4c 100644
>> --- a/memory.c
>> +++ b/memory.c
>> @@ -2422,8 +2422,10 @@ AddressSpace
>> *address_space_init_shareable(MemoryRegion *root, const char *name)
>> AddressSpace *as;
>>
>> QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
>> - if (root == as->root && as->malloced) {
>> - as->ref_count++;
>> + if (root == as->root) {
>> + if (as->malloced) {
>> + as->ref_count++;
>> + }
>> return as;
>> }
>> }
>>
This is wrong. If as->malloced is false, the AddressSpace might be
embedded in another struct. This other struct could be freed when
as->ref_count is still greater than 0, causing a use-after-free bug.
Paolo
prev parent reply other threads:[~2017-03-09 16:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-08 15:11 [Qemu-devel] [PATCH] memory: reduce heap Rss size around 3M Yang Zhong
2017-03-08 11:17 ` Philippe Mathieu-Daudé
2017-03-09 16:34 ` Paolo Bonzini [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=0c8f4fb6-89c4-84a5-6bbe-8fa849f17764@redhat.com \
--to=pbonzini@redhat.com \
--cc=anthony.xu@intel.com \
--cc=f4bug@amsat.org \
--cc=qemu-devel@nongnu.org \
--cc=yang.zhong@intel.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).