On Sat, 2017-10-28 at 00:19 +0200, Alex Williamson wrote: > On Fri, 27 Oct 2017 21:50:43 +0000 > "Wang, Liang-min" <liang-min.wang@xxxxxxxxx> wrote: > > > > -----Original Message----- > > > From: Alex Williamson [mailto:alex.williamson@xxxxxxxxxx] > > > Sent: Tuesday, October 24, 2017 6:07 PM > > > To: Wang, Liang-min <liang-min.wang@xxxxxxxxx> > > > Cc: Kirsher, Jeffrey T <jeffrey.t.kirsher@xxxxxxxxx>; kvm@xxxxxxxxxxxxxxx; > > > linux-pci@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; > > > bhelgaas@xxxxxxxxxx; Duyck, Alexander H <alexander.h.duyck@xxxxxxxxx> > > > Subject: Re: [PATCH] Enable SR-IOV instantiation through /sys file > > > > > > On Tue, 24 Oct 2017 21:49:15 +0000 > > > "Wang, Liang-min" <liang-min.wang@xxxxxxxxx> wrote: > > > > > > > Just like any PCIe devices that supports SR-IOV. There are restrictions set for > > > > > > VF. Also, there is a concept of trust VF now available for PF to manage certain > > > features that only selected VF could exercise. Are you saying all the devices > > > supporting SR-IOV all have security issue? > > > > > > Here's a simple example, most SR-IOV capable NICs, including those from > > > Intel, require the PF interface to be up in order to route traffic from > > > the VF. If the user controls the PF interface and VFs are used > > > elsewhere in the host, the PF driver in userspace can induce a denial > > > of service on the VFs. That doesn't even take into account that VFs > > > might be in separate IOMMU groups from the PF and therefore not > > > isolated from the host like the PF and that the PF driver can > > > potentially manipulate the VF, possibly performing DMA on behalf of the > > > PF. VFs are only considered secure today because the PF is managed by > > > a driver in the host kernel. Allowing simple enablement of VFs for a > > > user owned PF seems inherently insecure to me. Thanks, > > > > > > Alex > > > > Firstly, the concern is on user-space PF driver based upon vfio-pci, this patch doesn't > > change PF behavior so with/without this patch, the concern remains the same. > > This patch enables SR-IOV to be enabled via the host on a user-owned > PF, how is this not a change in behavior? > > > Secondly, the security concern (including denial of service) in general is to ensure trust > > entity to be trust-worthy. No matter the PF driver is in kernel-space or in user- space, > > necessary mechanism needs to be enforced on the device driver to ensure it's > > trusted worthy. For example, ixgbe kernel driver introduces a Tx hang detection > > to avoid driver stays in a bad state. Therefore, it's the responsibility of user-space > > driver function, which based upon vfio-pci, to enforce necessary mechanism to ensure > > its trust-ness. That's a given. > > Userspace is not trustworthy, therefore the host kernel cannot place > responsibility on a userspace driver for anything, including the > behavior of VFs. I'm sorry, but it's a NAK unless you intend to > follow-up with some proposal to quarantine the VFs enabled by the > userspace PF driver. Thanks, > > Alex I don't see this so much as a security problem per-se. It all depends on the hardware setup. If I recall correctly, there are devices where the PF function doesn't really do much other than act as a bit more heavy-weight VF, and the actual logic is handled by a firmware engine on the device. The only real issue is that for devices like the Intel NICs instead of trusting a firmware engine we have historically used a kernel driver and now we are wanting to trust a user-space agent instead. I do think that we probably need to have some sort of signaling between user-space and vfio-pci that would allow for notifying the user-space of the change and for user-space to notify vfio-pci that it is capable of handling the notification. This is something that can be toggled at any time after all and not all devices have a means of notifying the PF that this has been changed. Beyond that once the root user enables the VFs I would kind of think they know what driver they have running them. Enabling VFs implies the root user trusts the application running on top of vfio-pci to handle the PF responsibly. At least that is how it works in my mind. Thanks. - Alexander (using full name since 2 Alexs in one thread can be confusing)