Bug 1366611

Summary: Core dumped when do secret-get-value
Product: Red Hat Enterprise Linux 7 Reporter: Yanqiu Zhang <yanqzhan>
Component: libvirtAssignee: John Ferlan <jferlan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dyuan, fjin, jsuchane, lhuang, mzhan, rbalakri, yafu, yanqzhan, yanyang, yisun, zpeng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-2.0.0-6.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:52:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
gdb.txt for gdb backtrace none

Description Yanqiu Zhang 2016-08-12 12:45:44 UTC
Created attachment 1190378 [details]
gdb.txt for gdb backtrace

Description of problem:
Core dumped when do secret-get-value

Version-Release number of selected component (if applicable):
libvirt-2.0.0-5.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Prepare a secret xml:
# cat secret.xml
<secret ephemeral='no' private='yes'>
<description>LUKS passphrase for the main hard drive of our mail
server</description>
<usage type='volume'>
<volume>/var/lib/libvirt/images/testvm.img</volume>
</usage>
</secret>

2.Define the secret
#  virsh secret-define secret.xml
Secret 84fe59dd-6a87-415a-8dc1-1a10a63eeb6e created

3.Do secret-get-value
# virsh secret-get-value 84fe59dd-6a87-415a-8dc1-1a10a63eeb6e
Segmentation fault (core dumped)


Actual results:
As Step 3 descripted.


Expected results:
Should not core dumped and should give an error for no value has been set.


Additional info:
1.It works well on rhel7.2 with libvirt-1.2.17-13.el7.x86_64:
# virsh secret-get-value 8e730bc8-4dc3-43f2-be52-4246716dc6f3
error: Secret not found: secret '8e730bc8-4dc3-43f2-be52-4246716dc6f3' does not have a value

2.# cat /var/log/libvirt/libvirt.log|grep error
2016-08-12 11:36:30.498+0000: 17740: error : secretGetValue:363 : Invalid secret: secret is private
2016-08-12 11:36:30.602+0000: 17739: error : virNetSocketReadWire:1623 : End of file while reading data: Input/output error

3.gdb backtrace: 
Pls refer to attachment: gdb.txt

Comment 2 John Ferlan 2016-08-15 12:11:36 UTC
posted a patch upstream :

http://www.redhat.com/archives/libvir-list/2016-August/msg00749.html

and pushed as:

commit 18701e9d6213be5a622d7c797f3a899b689e26b2
Author: John Ferlan <jferlan>
Date:   Mon Aug 15 07:53:45 2016 -0400

    virsh: Fix core for cmdSecretGetValue
    
...
    
    When commit id 'cb2e3e50' reworked the cmdSecretGetValue call to use
    VIR_DISPOSE_STRING for base64, it neglected to initialize the base64
    value to NULL since the cleanup: label could be reached prior to the
    base64 value being set or not.  This resulted in a core dump, adding
    the initialization will avoid the issue.


git describe 18701e9d6213be5a622d7c797f3a899b689e26b2
v2.1.0-129-g18701e9

Comment 3 John Ferlan 2016-08-15 14:13:51 UTC
POSTed to rhvirt-patches:

http://post-office.corp.redhat.com/archives/rhvirt-patches/2016-August/msg00844.html

Comment 5 yisun 2016-08-26 02:26:41 UTC
Verified on libvirt-2.0.0-6.el7.x86_64 and PASSED


steps:
# virsh secret-list
 UUID                                  Usage
--------------------------------------------------------------------------------
 3c3d6381-f65a-463f-b394-6ea93766262d  volume /var/lib/libvirt/images/121.qcow2
 4ff78f8c-6ee6-4a8d-b638-2b59d5d49279  volume /var/lib/libvirt/images/luks/luks_1.img

# virsh secret-dumpxml 4ff78f8c-6ee6-4a8d-b638-2b59d5d49279
<secret ephemeral='no' private='yes'>
  <uuid>4ff78f8c-6ee6-4a8d-b638-2b59d5d49279</uuid>
  <description>LUKS Sample Secret</description>
  <usage type='volume'>
    <volume>/var/lib/libvirt/images/luks/luks_1.img</volume>
  </usage>
</secret>


# virsh secret-dumpxml 3c3d6381-f65a-463f-b394-6ea93766262d
<secret ephemeral='no' private='no'>
  <uuid>3c3d6381-f65a-463f-b394-6ea93766262d</uuid>
  <usage type='volume'>
    <volume>/var/lib/libvirt/images/121.qcow2</volume>
  </usage>
</secret>


# virsh secret-get-value 3c3d6381-f65a-463f-b394-6ea93766262d
K1JsXDpxIF5EaiEnW1ZnIw==


# virsh secret-get-value 4ff78f8c-6ee6-4a8d-b638-2b59d5d49279
error: Invalid secret: secret is private

Comment 7 errata-xmlrpc 2016-11-03 18:52:32 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-2577.html