From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b88pR-0001cI-Cp for qemu-devel@nongnu.org; Wed, 01 Jun 2016 12:17:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b88pN-00034j-2y for qemu-devel@nongnu.org; Wed, 01 Jun 2016 12:17:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b88pM-00034e-RE for qemu-devel@nongnu.org; Wed, 01 Jun 2016 12:17:05 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 747B27F092 for ; Wed, 1 Jun 2016 16:17:04 +0000 (UTC) References: <1464712247-11655-1-git-send-email-wexu@redhat.com> <20160531164448.GE21628@redhat.com> From: Wei Xu Message-ID: <574F0A7B.5030401@redhat.com> Date: Thu, 2 Jun 2016 00:16:59 +0800 MIME-Version: 1.0 In-Reply-To: <20160531164448.GE21628@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC Patch 0/3] Accept passed in socket 'fd' open from outside for unix socket List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: armbru@redhat.com, eblake@redhat.com, amit.shah@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org, mprivozn@redhat.com On 2016=E5=B9=B406=E6=9C=8801=E6=97=A5 00:44, Daniel P. Berrange wrote: > On Wed, Jun 01, 2016 at 12:30:44AM +0800, wexu@redhat.com wrote: >> From: Wei Xu >> >> Recently I'm working on a fd passing issue, selinux forbids qemu to >> create a unix socket for a chardev when managing VMs with libvirt, >> because qemu don't have sufficient permissions in this case, and >> proposal from libvirt team is opening the 'fd' in libvirt and merely >> passing it to qemu. > > This sounds like a bug in libvirt, or selinux, or a mistaken configurat= ion > of the guest. It is entirely possible for QEMU to create a unix socket = - not > least because that is exactly what QEMU uses for its QMP monitor backen= d. > Looking at your example command line, I think the issue is simply that = you > should be putting the sockets in a different location. ie at > /var/lib/libvirt/qemu/$guest-vhost-user1.sock where QEMU has permission= to > create sockets already. ah.. adjusting permission or file location can solve this problem, i'm=20 guessing maybe this is a more security concern, the socket is used as a=20 network interface for a vm, similar as the qcow image file, thus should=20 prevent it to be arbitrarily accessed. Michael, do you have any comment on this? > > Alternatively you could enhance the SELinux policy to grant svirt_t the > permission to create sockets under /var/run/openvswitch too. > >> I finished a RFC patch for Unix socket after a glance of the code, >> and not sure if this is right or there maybe other side-effects, >> please point me out. >> >> I tested it for both server and client mode 'PF_UNIX' socket with a VM >> running vhost-user. >> >> Old command line: >> -chardev socket,id=3Dchar0,path=3D/var/run/openvswitch/vhost-user1,ser= ver >> >> New command line: >> -chardev socket,id=3Dchar0,path=3D/var/run/openvswitch/vhost-user1,ser= ver,sockfd=3D$n >> >> because unix socket is bundled with a path, so it should be kept even = with the >> 'fd' is indicated, this looks odd, any comments? > > Yes, this syntax doesn't really make sense. The passed in sockfd may no= t > even be a UNIX socket - it could be a TCP socket. As such, the 'sockfd' > option should be mutually exclusive with the 'path' and 'host' options. > ie you can only supply one out of 'sockfd', 'path', or 'host'. Currently i just add it for unix socket, and the connect/listen syscall=20 must have a path name, an inet socket doesn't need this param at all,=20 should it be supported also? > > > FWIW, I think the ability to pass a pre-opened socket FD with the > -chardev socket backend is a useful enhancement, even though I don't > think you need this in order to fix the problem you have. OK, thanks for you quick feedback, i just wonder if 'add-fd' and=20 qemu_open() can be a more general solution. > > Regards, > Daniel >