RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1395496 - Libvirt allow paths symbol in ivshmem-plain/ivshmem name and qemu can access file out of /dev/shm
Summary: Libvirt allow paths symbol in ivshmem-plain/ivshmem name and qemu can access ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.3
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Martin Kletzander
QA Contact: Jingjing Shao
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-16 03:20 UTC by Luyao Huang
Modified: 2017-08-01 23:59 UTC (History)
4 users (show)

Fixed In Version: libvirt-3.2.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-01 17:19:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2017:1846 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2017-08-01 18:02:50 UTC

Description Luyao Huang 2016-11-16 03:20:03 UTC
Description of problem:
Libvirt allow paths symbol in ivshmem-plain/ivshmem name and qemu can access file out of /dev/shm

Version-Release number of selected component (if applicable):
libvirt-2.0.0-10.el7_3.2.x86_64

How reproducible:
100%

Steps to Reproduce:
1. prepare a guest with ivshmem-plain device like this:

    <shmem name='../../var/lib/libvirt/qemu/test-ivshmem'>
      <model type='ivshmem-plain'/>
      <size unit='M'>4</size>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </shmem>


2. start guest:

# virsh start r7
Domain r7 started

3. check qemu cmd line:

# ps aux|grep qemu
...
-object memory-backend-file,id=shmmem-shmem0,mem-path=/dev/shm/../../var/lib/libvirt/qemu/test-ivshmem,size=4194304,share=yes...

4. check qemu file:

# lsof /var/lib/libvirt/qemu/test-ivshmem
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
qemu-kvm 11816 qemu  mem    REG  253,0  4194304 67632139 /var/lib/libvirt/qemu/test-ivshmem
qemu-kvm 11816 qemu   22u   REG  253,0  4194304 67632139 /var/lib/libvirt/qemu/test-ivshmem


Actual results:

qemu can access file out of /dev/shm

Expected results:

I think it will be nice if libvirt forbid use paths symbol in ivshmem/ivshmem-plain name, and since guest can direct access that file on host.

Additional info:

Comment 2 Jaroslav Suchanek 2017-04-04 08:24:35 UTC
Related upstream commit:

commit 1c06d0faba152170de664f3ff4017cf4b59b44e4
Author:     Martin Kletzander <mkletzan>
AuthorDate: Wed Feb 1 17:14:00 2017 +0100
Commit:     Martin Kletzander <mkletzan>
CommitDate: Tue Feb 21 12:47:24 2017 +0100

    qemu: Forbid slashes in shmem name
    
    With that users could access files outside /dev/shm.  That itself
    isn't a security problem, but might cause some errors we want to
    avoid.  So let's forbid slashes as we do with domain and volume names
    and also mention that in the schema.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1395496
    
    Signed-off-by: Martin Kletzander <mkletzan>

v3.0.0-261-g1c06d0f

Comment 4 Jingjing Shao 2017-05-16 11:12:20 UTC
Verify this bug as below.

# rpm -q libvirt
libvirt-3.2.0-5.el7.x86_64

# virsh edit r7.2

Add this xml as below to guest xml
 <shmem name='../../var/lib/libvirt/test-ivshmem'>
   <model type='ivshmem-plain'/>
    <size unit='M'>4</size>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
 </shmem>

Get the error as below

error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content

Failed. Try again? [y,n,i,f,?]: 

enter i finish the edit 
Domain r7.2 XML configuration edited.

# virsh start r7.2
error: Failed to start domain r7.2
error: unsupported configuration: shmem name '../../var/lib/libvirt/test-ivshmem' must not contain '/'

Edit the guest xml as below.
<shmem name='test-ivshmem'>
 <model type='ivshmem-plain'/>
  <size unit='M'>4</size>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</shmem>

# virsh start r7.2
Domain r7.2 started

# ps aux|grep qemu  | grep shmmem
.....
-object memory-backend-file,id=shmmem-shmem0,mem-path=/dev/shm/test-ivshmem,size=4194304,share=yes -device ivshmem-plain,id=shmem0,memdev=shmmem-shmem0,bus=pci.0,addr=0x3 -msg timestamp=on
....

Comment 5 errata-xmlrpc 2017-08-01 17:19:14 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://access.redhat.com/errata/RHEA-2017:1846

Comment 6 errata-xmlrpc 2017-08-01 23:59:00 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://access.redhat.com/errata/RHEA-2017:1846


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