From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3428C433FE for ; Mon, 7 Nov 2022 18:10:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233036AbiKGSKT (ORCPT ); Mon, 7 Nov 2022 13:10:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232641AbiKGSJv (ORCPT ); Mon, 7 Nov 2022 13:09:51 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8507F252A3 for ; Mon, 7 Nov 2022 10:05:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667844313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bfWNmfGx0Se3BNvqmrQIw4qequKgdbo0qhO8fe0yzVg=; b=WxRUx4V6o663OGpq/ugPv4sPvahtdNLxBi+m+WYwLgN3c4jA3fEsQqaBOne5yKDSJGu4Y0 w9RgWk/2qiHYvSdK8MGUc3uPAmtymvI1IGi2Td45tQD/y6JmhGpj7dQcq2DY8NyFLsBKDZ sAtFGsK2z0ugBlRHvyMRclI7TN1EkNk= Received: from mail-il1-f200.google.com (mail-il1-f200.google.com [209.85.166.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-616-Yjkkkyr4PPqd1176s6Furg-1; Mon, 07 Nov 2022 13:05:12 -0500 X-MC-Unique: Yjkkkyr4PPqd1176s6Furg-1 Received: by mail-il1-f200.google.com with SMTP id o13-20020a056e0214cd00b00300a27f9424so9271987ilk.10 for ; Mon, 07 Nov 2022 10:05:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bfWNmfGx0Se3BNvqmrQIw4qequKgdbo0qhO8fe0yzVg=; b=reSv30RWAwNlkgqgWz2TQj+FpAbWNZS2bTos6lOIYhUZ0WWt8NHNPAoYRiJE3OhzDN C0hLl8vz8NX6e7Ptlzdx/rG1RQAaARhw1msxOEm53j/nNpi0DF+R83iPWP5OV4H+LVD9 V8A9VqW4Ymo84AZfg1cCxTApy75IVdCiWl9a7W/GIY7fxyMlNnVwPkFo4FHXwxIFjHH8 I4W1XlUWu/eTaQlw3wdX8puZfO6D+6JIr4Hf+VEbDVFH5Iff1nGHfJTn5PVOuUm7GXpX gDY2iQJ80IRWeTJ7CDZvi5jUKdyJ7zql7Z54lxGGWIt/nFDbC03ykEpyye5G1+fJ5cU7 Uuxg== X-Gm-Message-State: ANoB5pmVZ6Zl70yZw9gv5hXA+1yfPMFZJw7xl4P5cWnjmwmFzPuJqFD9 PEA2ts/XCwkB2tz2ASEpDVU5+cEw/DUf2Mg0L2NhQ6YyEXEvKIynaFkYKw9Hh7dlaFPkOxUiZod sd90ulJpeD3/U1NR/ZKlUbg== X-Received: by 2002:a05:6638:3590:b0:375:c920:16c2 with SMTP id v16-20020a056638359000b00375c92016c2mr2016469jal.72.1667844311316; Mon, 07 Nov 2022 10:05:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf6UQp/k2xL9xkcSh0+31rabNkEHgXJoe54k/D6xhd/Fo7jMB2KvouVPSBE3IOX+71t7NIX5PA== X-Received: by 2002:a05:6638:3590:b0:375:c920:16c2 with SMTP id v16-20020a056638359000b00375c92016c2mr2016445jal.72.1667844311051; Mon, 07 Nov 2022 10:05:11 -0800 (PST) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id g5-20020a05663810e500b00374d6db7566sm2912129jae.117.2022.11.07.10.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 10:05:10 -0800 (PST) Date: Mon, 7 Nov 2022 11:05:08 -0700 From: Alex Williamson To: Jason Gunthorpe Cc: kvm@vger.kernel.org, Kevin Tian , dri-devel@lists.freedesktop.org, Vineeth Vijayan , Diana Craciun , Alexander Gordeev , Longfang Liu , linux-s390@vger.kernel.org, Yi Liu , Matthew Rosato , Will Deacon , Joerg Roedel , Halil Pasic , iommu@lists.linux.dev, Nicolin Chen , Christian Borntraeger , intel-gfx@lists.freedesktop.org, Zhi Wang , Jason Herne , Eric Farman , Vasily Gorbik , Heiko Carstens , Eric Auger , Harald Freudenberger , Rodrigo Vivi , intel-gvt-dev@lists.freedesktop.org, Tony Krowiak , Tvrtko Ursulin , Yishai Hadas , Cornelia Huck , Peter Oberparleiter , Shameer Kolothum , Sven Schnelle , Robin Murphy , Lu Baolu Subject: Re: [PATCH 04/10] vfio: Move storage of allow_unsafe_interrupts to vfio_main.c Message-ID: <20221107110508.7f02abf4.alex.williamson@redhat.com> In-Reply-To: References: <0-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> <4-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> <20221026152442.4855c5de.alex.williamson@redhat.com> <20221031164526.0712e456.alex.williamson@redhat.com> <20221107081853.18727337.alex.williamson@redhat.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org On Mon, 7 Nov 2022 11:32:40 -0400 Jason Gunthorpe wrote: > On Mon, Nov 07, 2022 at 08:18:53AM -0700, Alex Williamson wrote: > > On Mon, 7 Nov 2022 09:19:43 -0400 > > Jason Gunthorpe wrote: > > > > > On Mon, Oct 31, 2022 at 04:45:26PM -0600, Alex Williamson wrote: > > > > > > > > It is one idea, it depends how literal you want to be on "module > > > > > parameters are ABI". IMHO it is a weak form of ABI and the need of > > > > > this paramter in particular is not that common in modern times, AFAIK. > > > > > > > > > > So perhaps we just also expose it through vfio.ko and expect people to > > > > > migrate. That would give a window were both options are available. > > > > > > > > That might be best. Ultimately this is an opt-out of a feature that > > > > has security implications, so I'd rather error on the side of requiring > > > > the user to re-assert that opt-out. It seems the potential good in > > > > eliminating stale or unnecessary options outweighs any weak claims of > > > > preserving an ABI for a module that's no longer in service. > > > > > > Ok, lets do this > > > > > > --- a/drivers/vfio/vfio_main.c > > > +++ b/drivers/vfio/vfio_main.c > > > @@ -55,6 +55,11 @@ static struct vfio { > > > bool vfio_allow_unsafe_interrupts; > > > EXPORT_SYMBOL_GPL(vfio_allow_unsafe_interrupts); > > > > > > +module_param_named(allow_unsafe_interrupts, > > > + vfio_allow_unsafe_interrupts, bool, S_IRUGO | S_IWUSR); > > > +MODULE_PARM_DESC(allow_unsafe_interrupts, > > > + "Enable VFIO IOMMU support for on platforms without interrupt remapping support."); > > > + > > > static DEFINE_XARRAY(vfio_device_set_xa); > > > static const struct file_operations vfio_group_fops; > > > > > > > However, I'd question whether vfio is the right place for that new > > > > module option. As proposed, vfio is only passing it through to > > > > iommufd, where an error related to lack of the hardware feature is > > > > masked behind an -EPERM by the time it gets back to vfio, making any > > > > sort of advisory to the user about the module option convoluted. It > > > > seems like iommufd should own the option to opt-out universally, not > > > > just through the vfio use case. Thanks, > > > > > > My thinking is this option shouldn't exist at all in other iommufd > > > users. eg I don't see value in VDPA supporting it. > > > > I disagree, the IOMMU interface is responsible for isolating the > > device, this option doesn't make any sense to live in vfio-main, which > > is the reason it was always a type1 option. > > You just agreed to this above? After further consideration... I don't think the option on vfio-main makes sense, basically for the same reason that the original option existed on the IOMMU backend rather than vfio-core. The option describes a means to relax a specific aspect of IOMMU isolation, which makes more sense to expose via the IOMMU provider, imo. For example, vfio-main cannot generate an equivalent error message as provided in type1 today, it's too far removed from the IOMMU feature support. > > If vdpa doesn't allow full device access such that it can guarantee > > that a device cannot generate a DMA that can spoof MSI, then it > > sounds like the flag we pass when attaching a device to iommfd > > should to reflect this difference in usage. > > VDPA allows arbitary DMA just like VFIO. At most VDPA limits the MMIO > touches. So why exactly isn't this an issue for VDPA? Are we just burying our head in the sand that such platforms exists and can still be useful given the appropriate risk vs reward trade-off? > > The driver either requires full isolation, default, or can indicate a > > form of restricted DMA programming that prevents interrupt spoofing. > > The policy whether to permit unsafe configurations should exist in one > > place, iommufd. > > iommufd doesn't know the level of unsafely the external driver is > creating, Thus the proposed flag. But maybe we don't need it if VDPA has no inherent protection against MSI spoofing itself. > and IMHO we don't actually want to enable this more > widely. So I don't want to see a global kernel wide flag at this point > until we get reason to make more than just VFIO insecure. But this brings into question the entire existence of the opt-in. Do we agree that there are valid use cases for such an option? Unlike things like ACS overrides, lack of interrupt isolation really requires a malicious actor. We're not going to inadvertently overlap DMA to interrupt addresses like we might to a non-isolated MMIO ranges. Therefore an admin can make a reasonable determination relative to the extent to which the userspace is trusted. This is not unlike opt-outs to CPU vulnerability mitigation imo, there are use cases where the performance or functionality is more important than the isolation. Hand waving this away as a vfio-unique insecurity is a bad precedent for iommufd. Thanks, Alex