From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] PATCH: Close file descriptors when execing network tap setup script
Date: Tue, 6 Mar 2007 16:28:43 +0000 [thread overview]
Message-ID: <20070306162843.GG29872@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 923 bytes --]
In the VM initialization, the files corresponding to the virtual disks are
opened before the networking is setup. So when the time comes to run the
network tap setup script the QEMU process has a bunch of open file handles
which are leaked to the networking script. Some of the commands run by the
networking script may well be executing under a confined SELinux domain so
this leak of file handles triggers security audit alerts / denials.
The attached patch explicitly closes all file handles prior to execing the
network script, except for STDIN/OUT/ERR and the TAP file handle itself.
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 #2: qemu-close-fds.patch --]
[-- Type: text/plain, Size: 816 bytes --]
Index: vl.c
===================================================================
RCS file: /sources/qemu/qemu/vl.c,v
retrieving revision 1.260
diff -u -p -r1.260 vl.c
--- vl.c 28 Feb 2007 21:59:44 -0000 1.260
+++ vl.c 6 Mar 2007 16:23:26 -0000
@@ -3620,6 +3620,14 @@ static int net_tap_init(VLANState *vlan,
pid = fork();
if (pid >= 0) {
if (pid == 0) {
+ int open_max = sysconf (_SC_OPEN_MAX), i;
+ for (i = 0; i < open_max; i++)
+ if (i != STDIN_FILENO &&
+ i != STDOUT_FILENO &&
+ i != STDERR_FILENO &&
+ i != fd)
+ close(i);
+
parg = args;
*parg++ = (char *)setup_script;
*parg++ = ifname;
reply other threads:[~2007-03-06 16:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070306162843.GG29872@redhat.com \
--to=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).