Red Hat Bugzilla – Bug 827234
potential to deadlock libvirt on EPIPE
Last modified: 2013-02-21 02:15:58 EST
Eric, from our email exchange it sounds like this behavior only results in the hang of a process already controlled by a user and cannot be exploited to do anything else. Can you confirm?
I've convinced myself that the deadlock can only happen if you call virCommandSetInputBuffer with more than PIPE_BUF bytes; the only places in our code base that makes these calls are security_apparmor.c (not relevant to RHEL) and hooks.c (but hooks are only run if you can install a shell hook, which means you can already do any number of other things), and therefore this is not a security bug - while it can be exploited to cause deadlock, such an exploit is not a Denial of Service where an unprivileged user is able to lock out a privileged user. I'm opening up visibility and posting the patch upstream.
Author: Eric Blake <email@example.com>
Date: Thu May 31 15:50:07 2012 -0600
command: avoid deadlock on EPIPE situation
It is possible to deadlock libvirt by having a domain with XML
longer than PIPE_BUF, and by writing a hook script that closes
stdin early. This is because libvirt was keeping a copy of the
child's stdin read fd open, which means the write fd in the
parent will never see EPIPE (remember, libvirt should always be
run with SIGPIPE ignored, so we should never get a SIGPIPE signal).
Since there is no error, libvirt blocks waiting for a write to
complete, even though the only reader is also libvirt. The
solution is to ensure that only the child can act as a reader
before the parent does any writes; and then dealing with the
fallout of dealing with EPIPE.
I can reproduce this issue on 'tag v0.9.10' after applied patch of 'tests/*', and the 'commandtest' will be hung forever due to dealock:
...................................... 38 OK
And it's okay without deadlock after applied patch of 'src/util/command.c'. So change the bug to VERIFIED status.
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.