[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] PATCH: Set close-on-exec flag for QEMU disks
On Mon, Mar 05, 2007 at 03:23:43PM -0600, Anthony Liguori wrote: > Keir Fraser wrote: > >On 2/3/07 21:40, "Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote: > > > > > >>QEMU does not currently set the close-on-exec flag after opening its > >>virtual > >>disk images. This causes problems when it later runs the > >>/etc/xen/qemu-ifup > >>script because the file descriptors get propagated to networking commands > >>like brctl / ifconfig. The SELinux policy quite rightly does not allow the > >>networking scripts to access the virtual disk images, so these inherited > >>file descriptors for AVC denials to be logged. > >> > >>The attached patch modifies all the QEMU disk driver backends to make sure > >>the close-on-exec flag is turned on > >> > > > >It would be nicer to implement an open_cloexec() function in e.g., vl.c to > >do the open() and fcntl() in one go and in one place. > > > > There are few areas where scripts are executed. Why not just introduce > an exec() wrapper that closes file descriptors appropriately. Looking at the QEMU code in Xen there are only two places where exec is used, and one of those is for the vncviewer spawning which isn't upstream. One of them uses execlp() while the other uses execv(). So rather than doing a refactoring of code which will lead to even more divergance with upstream, the attached patch just fixes up those 2 locations to close all file handles upto sysconf(_SC_OPEN_MAX), with exception of STDIN/OUT/ERR and the TAP deevice handle. Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> I've tested against Xen 3.0.4 in Fedora to validate neither the qemu-ifup or vncviewer processes receive any extraneous file handles. The attached patch applies cleanly to xen-unstable.hg too Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=| Attachment:
xen-qemu-close-fds-2.patch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |