[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 1/1] Fix the crash when seclable is freed

On 02/04/13 16:04, Li Zhang wrote:
On 2013年04月02日 15:03, Li Zhang wrote:
On 2013年04月02日 14:47, Osier Yang wrote:
On 02/04/13 13:58, Li Zhang wrote:
From: Li Zhang <zhlcindy linux vnet ibm com>

When seclabel's type is VIR_DOMAIN_SECLABEL_NONE,
virSecurityLabelDefPtr's members are not allocated.
So it will cause crash when calling VIR_FREE.

This problem is found when running autotest on PPC.

Failed to remove cgroup for virt-tests-vm1
*** glibc detected *** /usr/sbin/libvirtd: free(): invalid pointer: 0x00003fff9c187510 ***
======= Backtrace: =========
/usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so(qemuProcessStop-0xc85f8)[0x3fffa2899d58] /usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so(+0xc3668)[0x3fffa28e3668]

Signed-off-by: Li Zhang <zhlcindy linux vnet ibm com>
src/conf/domain_conf.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f3fca7f..2856660 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1006,6 +1006,8 @@ virSecurityLabelDefFree(virSecurityLabelDefPtr def)
if (!def)
+ if (def->type == VIR_DOMAIN_SECLABEL_NONE)
+ return;

model is always parsed. So it will be leaked if someone specifies
"model" even the type is "none".
Okay, it seems that is not always non-NULL although it is always parsed.

My XML file is as:
<seclabel type='none'/>

It should be better to add if clause before VIR_FREE.

Sorry, it seems that this is not right solution to resolve the problem.
free(ptr): ptr can be NULL.
This root cause is because of invalid pointer which is not NULL.
I need to find out the invalid pointer.

The solution is not to parse "model" when the seclabel type is "none".
I might not be 100% correct. But I think the "model" is just useless
for "none". Then your patch is right.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]