Bug 287811 - libvirt: fix segmentation fault when buffer needs to be reallocated
libvirt: fix segmentation fault when buffer needs to be reallocated
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: libvirt (Show other bugs)
5.1
All Linux
urgent Severity high
: rc
: ---
Assigned To: Daniel Veillard
Virtualization Bugs
GSSApproved
: ZStream
Depends On:
Blocks: 430876
  Show dependency treegraph
 
Reported: 2007-09-12 11:47 EDT by Flavio Leitner
Modified: 2010-10-22 14:36 EDT (History)
2 users (show)

See Also:
Fixed In Version: RHBA-2008-0291
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-05-21 12:47:41 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Flavio Leitner 2007-09-12 11:47:54 EDT
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 11:47:54 EDT
Created attachment 193581 [details]
Backported patch from upstream
Comment 2 RHEL Product and Program Management 2007-10-15 23:40:25 EDT
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 08:36:16 EST
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 08:43:12 EST
Setting dev ack as this is fixed as per comment #4.
Comment 14 errata-xmlrpc 2008-05-21 12:47:41 EDT
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.