From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a4-smtp.messagingengine.com (fhigh-a4-smtp.messagingengine.com [103.168.172.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03C8B38D6B1; Thu, 30 Apr 2026 20:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777580041; cv=none; b=HFj8+H2P7AR5rF/FOPrgGzQA/oqVyClb7esfINhpUDfWROiQi+MvrMwR6TCxScppH3XOSy9mIr1niQpSJ+3osCCJT8O795TeEvbh5x9QToxZR4jPz8XjwY3N/WcHE70Ccu4R0DpWyRw36b+zDTJRzjQn7215pewHyo60EyU58U0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777580041; c=relaxed/simple; bh=aDsCu3z80QPVoVoKfmhKYpp3qc/i+wge3CyQtaksykc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VczVk6Q8ndFLXywwTQrBXZ2aJDC3I8+nb2iGcIZAcE3/N890CqXwE5ASZj1OCwXanezSp1WZwnyffLgcOERCKLxnZb4ZWT1jcUES68C70dK5qZub/QrA7H4+6wEpZrGy1TrTOceTnXm3mOLk3vN6NqwryY35ZcMVXHN/g1W+lUM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org; spf=pass smtp.mailfrom=shazbot.org; dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org header.b=F7zDOruJ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QhcpOjG3; arc=none smtp.client-ip=103.168.172.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shazbot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org header.b="F7zDOruJ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QhcpOjG3" Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id 5F7B91400116; Thu, 30 Apr 2026 16:13:58 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Thu, 30 Apr 2026 16:13:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shazbot.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1777580038; x=1777666438; bh=cIWUfOtmNgofCmZE+cELVNsQTIEZ0ZyUaH/wBFQLd3I=; b= F7zDOruJQXQ8mLKLQJttYHVqPhz09unuo2SGsuJcrRI8wic60b5zgSYVPzIkrVQ5 +n+9LSAygmWqPOe2IXqaqDqPyZ2DHHL8CVkiqxCdAJFFjpeoVKK8CjgSWElz1vjM WL7LF6XWshYPfKlWEe8vpcJkG2/4udHeF3FC5hnGxJR6sKSPkFxM/dIKcHVkzbH0 aDRvr1VFLhTTMZIII3ZNJ5T7401pK4Bg5KnFigcQDyQ93WGNxb4zLcWmHvDU3WlL yY9m+eSxOQ8q+SX29el8e6Nr0lhWhSImA/RGib1Q/yKGKsB7lijvKFEPdJoGcSoZ 5WHg0aNfXuFzzbZnuD0IbA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1777580038; x= 1777666438; bh=cIWUfOtmNgofCmZE+cELVNsQTIEZ0ZyUaH/wBFQLd3I=; b=Q hcpOjG3lfcddc6eaEvhvdn6vYzAItFt6ozbIZQLaf3XPgRziuQkR+pCDXhpus3H6 9MZE+j+dC7uo5nwLEGC1GGTw+VJvXsGF0sIkWBvoyzSmqUyO/tPd9MS0LXplZrjl 9xXg8IYlZn/gy9VaASoolAV1zllMcBYHO+uqgRbf5UzwByXNgLpVQeLGtcV6MfXy 7Vk3N0JXTJK2+uyz1fm2zicskGmIZaPe0OfB6lQJanhCF4BG9y7GKgzBYiJiWHtI vPpu4CEKFSiat/zaWKGVsyhSfH2CKdTRSnXrnHHsVvzgvwjdADfbrgA4vfNk0Jy6 j4x9jmpUeK6qYb98UtMAA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekkedvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfgjfhfogggtgfesthejredtredtvdenucfhrhhomheptehlvgigucgh ihhllhhirghmshhonhcuoegrlhgvgiesshhhrgiisghothdrohhrgheqnecuggftrfgrth htvghrnhepvdekfeejkedvudfhudfhteekudfgudeiteetvdeukedvheetvdekgfdugeev ueeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hlvgigsehshhgriigsohhtrdhorhhgpdhnsggprhgtphhtthhopedukedpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepmhgrthhtvghvsehmvghtrgdrtghomhdprhgtphhtth hopehkvghvihhnrdhtihgrnhesihhnthgvlhdrtghomhdprhgtphhtthhopehjghhgseii ihgvphgvrdgtrgdprhgtphhtthhopegrnhhkihhtrgesnhhvihguihgrrdgtohhmpdhrtg hpthhtoheprghpohhpphhlvgesnhhvihguihgrrdgtohhmpdhrtghpthhtoheplhgvohhn sehkvghrnhgvlhdrohhrghdprhgtphhtthhopehkvggvsheskhgvrhhnvghlrdhorhhgpd hrtghpthhtohepshhkohhlohhthhhumhhthhhosehnvhhiughirgdrtghomhdprhgtphht thhopeihihhshhgrihhhsehnvhhiughirgdrtghomh X-ME-Proxy: Feedback-ID: i03f14258:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 Apr 2026 16:13:56 -0400 (EDT) Date: Thu, 30 Apr 2026 14:13:55 -0600 From: Alex Williamson To: Matt Evans Cc: Kevin Tian , Jason Gunthorpe , Ankit Agrawal , Alistair Popple , Leon Romanovsky , Kees Cook , Shameer Kolothum , Yishai Hadas , Alexey Kardashevskiy , Eric Auger , Peter Xu , Vivek Kasireddy , Zhi Wang , , , , alex@shazbot.org Subject: Re: [PATCH v3 3/3] vfio/pci: Check BAR resources before exporting a DMABUF Message-ID: <20260430141355.2751f9ff@shazbot.org> In-Reply-To: <20260430100340.2787446-4-mattev@meta.com> References: <20260430100340.2787446-1-mattev@meta.com> <20260430100340.2787446-4-mattev@meta.com> X-Mailer: Claws Mail 4.3.1 (GTK 3.24.51; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 30 Apr 2026 03:03:22 -0700 Matt Evans wrote: > A DMABUF exports access to BAR resources and, although they are > requested at startup time, we need to ensure they really were reserved > before exporting. Otherwise, it's possible to access unreserved > resources through the export. > > Add a check to the DMABUF-creation path. > > Fixes: 5d74781ebc86c ("vfio/pci: Add dma-buf export support for MMIO regions") > Signed-off-by: Matt Evans > --- > drivers/vfio/pci/vfio_pci_dmabuf.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci_dmabuf.c > index f87fd32e4a01..3bc7d850e258 100644 > --- a/drivers/vfio/pci/vfio_pci_dmabuf.c > +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c > @@ -244,9 +244,11 @@ int vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags, > return -EINVAL; > > /* > - * For PCI the region_index is the BAR number like everything else. > + * For PCI the region_index is the BAR number like everything > + * else. Check that PCI resources have been claimed for it. > */ > - if (get_dma_buf.region_index >= VFIO_PCI_ROM_REGION_INDEX) > + if (get_dma_buf.region_index >= VFIO_PCI_ROM_REGION_INDEX || > + !IS_ERR(vfio_pci_core_get_iomap(vdev, get_dma_buf.region_index))) Polarity of the test is wrong, should just be IS_ERR(). It would be good practice here to front-load the Fixes: patches in your series. I'd suggest making this patch #2, using the existing setup_barmap API, then include it in the conversion to iomap in patch #3. Thanks, Alex