Bug 287811 - libvirt: fix segmentation fault when buffer needs to be reallocated
Summary: libvirt: fix segmentation fault when buffer needs to be reallocated
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: libvirt
Version: 5.1
Hardware: All
OS: Linux
urgent
high
Target Milestone: rc
: ---
Assignee: Daniel Veillard
QA Contact: Virtualization Bugs
URL:
Whiteboard: GSSApproved
Depends On:
Blocks: 430876
TreeView+ depends on / blocked
 
Reported: 2007-09-12 15:47 UTC by Flavio Leitner
Modified: 2018-10-19 22:03 UTC (History)
2 users (show)

Fixed In Version: RHBA-2008-0291
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-05-21 16:47:41 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Backported patch from upstream (1.72 KB, patch)
2007-09-12 15:47 UTC, Flavio Leitner
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2008:0291 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2008-05-20 14:37:31 UTC

Description Flavio Leitner 2007-09-12 15:47:54 UTC
Description of problem:

When the specified number of characters is short, this issue does not
occur because the pointer of ret is same as buf.content.
But when that is long (i.e. exceeds 4000 bytes), this issue occurs
because the wrong pointer is returned.

So, we fixed the return value to not abend because of an excess number
of characters.

Here is a sequence of these case.
---------------------------------------------------------------------
the case of specifying short command line:

                    +--------------------------+
ret = buf.content => l malloc(4000)             l
                    +--------------------------+
                   0x10 (pointer to the allocated memory)

return(ret)
---------------------------------------------------------------------
the case of specifying long command line:

                    +--------------------------+
ret = buf.content => l malloc(4000)             l
                    +--------------------------+
                   0x10 (pointer to the allocated memory)

** When the allocated memory is lacking, the size of the memory is **
** changed by realloc at virBufferVSprintf.                        **
** So the area pointed to was moved.                               **

                    +--------------------------+
             ret => l malloc(4000)             l
                    +--------------------------+
                   0x10 (pointer to the previously allocated memory)

                    +---------------------------------+
     buf.content => l realloc(6000)                   l
                    +---------------------------------+
                   0x30 (pointer to the newly allocated memory.)

return(ret) <-- return the wrong pointer.
---------------------------------------------------------------------

Version-Release number of selected component (if applicable):
libvirt-0.2.3-9.el5

How reproducible:
Always

Steps to Reproduce:
Run a bug line like:
1. Run:
# virt-install --name=test --ram=350 --file=/dev/sda5 --paravirt \
   --location=ftp://10.131.236.20/rhel5.1b_ia64< /a> --vnc --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge ...

  
Actual results:
Segfault

Additional info:
Patch submitted to upstream and applied:
https://www.redhat.com/archives/libvir-list/2007-August/msg00220.html

Backported patch to RHEL5 attached.

This ticket comes from IT#130873 and is related to BZ#273421 too.

Comment 1 Flavio Leitner 2007-09-12 15:47:54 UTC
Created attachment 193581 [details]
Backported patch from upstream

Comment 2 RHEL Program Management 2007-10-16 03:40:25 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 4 Daniel Veillard 2008-01-23 13:36:16 UTC
The patch for this issue is actually in the current libvirt-0.3.3-4.el5
package being built for 5.2,

Daniel

Comment 5 Bill Burns 2008-01-23 13:43:12 UTC
Setting dev ack as this is fixed as per comment #4.


Comment 14 errata-xmlrpc 2008-05-21 16:47:41 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2008-0291.html



Note You need to log in before you can comment on or make changes to this bug.