• E
    audit: audit use of /dev/net/tun, /dev/tapN, /dev/vhost-net · 9516a0ec
    Eric Blake 提交于
    Opening raw network devices with the intent of passing those fds to
    qemu is worth an audit point.  This makes a multi-part audit: first,
    we audit the device(s) that libvirt opens on behalf of the MAC address
    of a to-be-created interface (which can independently succeed or
    fail), then we audit whether qemu actually started the network device
    with the same MAC (so searching backwards for successful audits with
    the same MAC will show which fd(s) qemu is actually using).  Note that
    it is possible for the fd to be successfully opened but no attempt
    made to pass the fd to qemu (for example, because intermediate
    nwfilter operations failed) - no interface start audit will occur in
    that case; so the audit for a successful opened fd does not imply
    rights given to qemu unless there is a followup audit about the
    attempt to start a new interface.
    
    Likewise, when a network device is hot-unplugged, there is only one
    audit message about the MAC being discontinued; again, searching back
    to the earlier device open audits will show which fds that qemu quits
    using (and yes, I checked via /proc/<qemu-pid>/fd that qemu _does_
    close out the fds associated with an interface on hot-unplug).  The
    code would require much more refactoring to be able to definitively
    state which device(s) were discontinued at that point, since we
    currently don't record anywhere in the XML whether /dev/vhost-net was
    opened for a given interface.
    
    * src/qemu/qemu_audit.h (qemuAuditNetDevice): New prototype.
    * src/qemu/qemu_audit.c (qemuAuditNetDevice): New function.
    * src/qemu/qemu_command.h (qemuNetworkIfaceConnect)
    (qemuPhysIfaceConnect, qemuOpenVhostNet): Adjust prototype.
    * src/qemu/qemu_command.c (qemuNetworkIfaceConnect)
    (qemuPhysIfaceConnect, qemuOpenVhostNet): Add audit points and
    adjust parameters.
    (qemuBuildCommandLine): Adjust caller.
    * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
    9516a0ec
qemu_command.h 6.9 KB