From: liulongfang <liulongfang@huawei.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
Alex Williamson <alex.williamson@redhat.com>
Cc: <cohuck@redhat.com>, <linux-kernel@vger.kernel.org>,
<linuxarm@openeuler.org>
Subject: Re: [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio
Date: Wed, 21 Apr 2021 17:59:04 +0800 [thread overview]
Message-ID: <8930d7db-2145-5cc3-ce6f-67dc3959d391@huawei.com> (raw)
In-Reply-To: <20210420231830.GD1370958@nvidia.com>
On 2021/4/21 7:18, Jason Gunthorpe wrote:
> On Tue, Apr 20, 2021 at 04:04:57PM -0600, Alex Williamson wrote:
>
>>> The migration control registers must be on a different VF from the VF
>>> being plugged into a guest and the two VFs have to be in different
>>> IOMMU groups to ensure they are isolated from each other.
>>
>> I think that's a solution, I don't know if it's the only solution.
>
> Maybe, but that approach does offer DMA access for the migration. For
> instance to implement something that needs a lot of data like
> migrating a complicated device state, or dirty page tracking or
> whatver.
>
> This driver seems very simple - it has only 17 state elements - and
> doesn't use DMA.
>
Yes,the operating address of this driver is the MMIO address,
not the DMA address, but the internal hardware DMA address is used
as data for migration.
> I can't quite tell, but does this pass the hypervisor BAR into the
> guest anyhow? That would certainly be an adquate statement that it is
> safe, assuming someone did a good security analysis.
>
>> ways and it's not very interesting. If the user can manipulate device
>> state in order to trigger an exploit of the host-side kernel driver,
>> that's obviously more of a problem.
>
> Well, for instance, we have an implementation of
> (VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RUNNING) which means the
> guest CPUs are still running and a hostile guest can be manipulating
> the device.
>
> But this driver is running code, like vf_qm_state_pre_save() in this
> state. Looks very suspicious.
>
> One quick attack I can imagine is to use the guest CPU to DOS the
> migration and permanently block it, eg by causing qm_mb() or other
> looping functions to fail.
>
> There may be worse things possible, it is a bit hard to tell just from
> the code.
>
> .. also drivers should not be open coding ARM assembly as in
> qm_mb_write()
>
OK, these codes need to be encapsulated and should not be presented in
this driver.
> .. and also, code can not randomly call pci_get_drvdata() on a struct
> device it isn't attached to haven't verified the right driver is
> bound, or locked correctly.
>
Yes, This call needs to be placed in an encapsulation interface,
and access protection needs to be added.
>> manipulate the BAR size to expose only the operational portion of MMIO
>> to the VM and use the remainder to support migration itself. I'm
>> afraid that just like mdev, the vfio migration uAPI is going to be used
>> as an excuse to create kernel drivers simply to be able to make use of
>> that uAPI.
>
> I thought that is the general direction people had agreed on during
> the IDXD mdev discussion?
>
> People want the IOCTLs from VFIO to be the single API to program all
> the VMMs to and to not implement user space drivers..
>
> This actually seems like a great candidate for a userspace driver.
>
> I would like to know we are still settled on this direction as the
> mlx5 drivers we are working on also have some complicated option to be
> user space only.
>
> Jason
> .
>
next prev parent reply other threads:[~2021-04-21 9:59 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-13 3:36 [RFC PATCH 0/3] vfio/hisilicon: add acc live migration driver Longfang Liu
2021-04-13 3:36 ` [RFC PATCH 1/3] " Longfang Liu
2021-04-13 3:36 ` [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio Longfang Liu
2021-04-15 22:01 ` Jason Gunthorpe
2021-04-19 12:24 ` liulongfang
2021-04-19 12:33 ` Jason Gunthorpe
2021-04-20 12:50 ` liulongfang
2021-04-20 12:59 ` Jason Gunthorpe
2021-04-20 13:28 ` liulongfang
2021-04-20 14:55 ` Jason Gunthorpe
2021-04-20 22:04 ` Alex Williamson
2021-04-20 23:18 ` Jason Gunthorpe
2021-04-21 9:59 ` liulongfang [this message]
2021-04-21 9:59 ` liulongfang
2021-04-21 18:12 ` Alex Williamson
2021-04-26 11:49 ` liulongfang
2021-05-12 8:39 ` liulongfang
2021-05-12 12:10 ` Jason Gunthorpe
2021-05-13 2:08 ` liulongfang
2021-05-13 13:44 ` Jason Gunthorpe
2021-05-13 15:49 ` [Linuxarm] " Shameerali Kolothum Thodi
2021-05-13 17:03 ` Alex Williamson
2021-05-13 17:52 ` Shameerali Kolothum Thodi
2021-05-13 18:22 ` Alex Williamson
2021-05-13 18:31 ` Shameerali Kolothum Thodi
2021-05-13 18:34 ` Jason Gunthorpe
2021-05-13 18:24 ` Jason Gunthorpe
2021-05-13 18:35 ` Shameerali Kolothum Thodi
2021-05-27 10:11 ` Shameerali Kolothum Thodi
2021-05-27 10:30 ` Max Gurtovoy
2021-04-13 3:36 ` [RFC PATCH 3/3] vfio/hisilicom: add debugfs for driver Longfang Liu
2021-04-15 21:35 ` [RFC PATCH 0/3] vfio/hisilicon: add acc live migration driver Alex Williamson
-- strict thread matches above, loose matches on Subject: below --
2021-04-13 1:20 [RFC PATCH v3 " Longfang Liu
2021-04-13 1:20 ` [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio Longfang Liu
2021-04-12 8:53 [RFC PATCH v3 0/3] vfio/hisilicon: add acc live migration driver Longfang Liu
2021-04-12 8:53 ` [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio Longfang Liu
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=8930d7db-2145-5cc3-ce6f-67dc3959d391@huawei.com \
--to=liulongfang@huawei.com \
--cc=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@openeuler.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).