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 1337005 - Log event when a block device in use by a guest is open read-write by external applications
Summary: Log event when a block device in use by a guest is open read-write by externa...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Yanqiu Zhang
URL:
Whiteboard:
Depends On:
Blocks: 1401400
TreeView+ depends on / blocked
 
Reported: 2016-05-18 02:07 UTC by Ademar Reis
Modified: 2017-12-14 16:03 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-12-14 16:03:04 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Ademar Reis 2016-05-18 02:07:06 UTC
With more users adopting KVM-based solutions (RHEV and OSP), we've
been receiving more escalations from GSS, as expected.

And one recurrent kind of escalation which usually arrives with a
very high priority is some sort of image corruption. Based on
recent history, these corruptions are not caused by QEMU, but the
burden of the investigation is usually on us.

I even remember hearing something like "we've seen corruptions in
the field" from somebody the other day, even though it's been a
while since the last time we fixed a real corruption bug in
RHEL/QEMU. In summary: when a corruption happens, we look
bad, even if it's not our fault.

Some recent examples:

 - The usual image corruption resulting from using qemu-img in an
   open image
   https://bugzilla.redhat.com/show_bug.cgi?id=1277167

 - os-probe (apparently from grub) remounts host partitions
   (read-only) when looking for additional OSes installed in the
   system. In case of XFS partitions, the journal gets replayed,
   resulting in corruption if they're being used by a guest
   https://bugzilla.redhat.com/show_bug.cgi?id=1304321

 - A hardware inventory program (from the customer) that decided
   it was a good idea to probe entries from /dev by sending a few
   bytes to each suspicious device (looking for printers, for
   example)
   https://bugzilla.redhat.com/show_bug.cgi?id=1241510

 - Strange qcow2 corruption in a setup with Ceph hosting qcow2
   images (after weeks of debugging, it turned out to be a race
   in Ceph's cache implementation, but it took us a long time just
   to exclude the possibility that the image was being open by
   a different process)
   https://bugzilla.redhat.com/show_bug.cgi?id=1308433

What all these problems have in common is that they took a long
time to debug, resulting in frustration for everybody: customers,
GSS and us.

So the question is: what can we do to improve the situation? Not
just prevent these issues from happening, but also improve the
tools we have to audit the problem?

Libvirt already does some locking and there's work upstream to add image locking to QEMU, thus preventing multiple QEMU or qemu-img from opening an image in use. But that is not enough. As can be seen im the examples above, we also need a mechanism to detect when other programs write to a block device (or image) used by QEMU.

From recent discussions, here are a few ideas:

    * libvirt -- permissions + SELinux to prevent users from
      accessing the block device in use

    * inotify: log a warning (or taint the domain) if the block device
      is opened by a different process
      * Use IN_CLOSE_WRITE event to detect when another process
        had the file open for writing? What about opening?

    * Integrate with auditctl (see https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Defining_Audit_Rules_and_Controls.html)

    * Raise requirements for API improvements in Ceph and Gluster

    * Figure out something for NFS hosted images

    * Have all I/O against network storage in a QEMU native backend
      not kernel (avoiding any issues with device nodes appearing in
      /dev on the host)

I'm assuming the best place for this kind of protection is in libvirt. Maybe it should be handled inside QEMU instead (although there are cases where the changes would have to be in QEMU). Most likely, a proper solution would involve changes in both QEMU and libvirt.

Comment 4 Peter Krempa 2017-12-14 16:03:04 UTC
I don't think this should be a part of libvirt. Libvirt provides events which can be used by management application to install watches for files if they wish so. Libvirt provides mechanisms (locking via sanlock or virtlockd) to avoid concurrent access to images between VMs, but other processes on the host are out of scope.


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