Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1366611 - Core dumped when do secret-get-value
Core dumped when do secret-get-value
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.3
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: John Ferlan
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-08-12 08:45 EDT by yanqzhan@redhat.com
Modified: 2016-11-03 14:52 EDT (History)
11 users (show)

See Also:
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 14:52:32 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
gdb.txt for gdb backtrace (3.94 KB, text/plain)
2016-08-12 08:45 EDT, yanqzhan@redhat.com
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2577 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2016-11-03 08:07:06 EDT

  None (edit)
Description yanqzhan@redhat.com 2016-08-12 08:45:44 EDT
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 08:11:36 EDT
posted a patch upstream :

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

and pushed as:

commit 18701e9d6213be5a622d7c797f3a899b689e26b2
Author: John Ferlan <jferlan@redhat.com>
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 10:13:51 EDT
POSTed to rhvirt-patches:

http://post-office.corp.redhat.com/archives/rhvirt-patches/2016-August/msg00844.html
Comment 5 yisun 2016-08-25 22:26:41 EDT
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 14:52:32 EDT
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

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