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 6F607C433EF for ; Mon, 14 Feb 2022 10:50:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236350AbiBNKuE (ORCPT ); Mon, 14 Feb 2022 05:50:04 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:38740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349291AbiBNKtS (ORCPT ); Mon, 14 Feb 2022 05:49:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12A37BF963; Mon, 14 Feb 2022 02:12:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A2EE660FF2; Mon, 14 Feb 2022 10:12:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DDDFC340E9; Mon, 14 Feb 2022 10:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644833547; bh=M0BF1S8k6P4/h+amgHnnMxnmmzIHRn78qIWiqCZMTt8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UptKleNcc93DXh/8y4no+0p/Hl1XMjhGS2P6HwvH72Ql1NOdZNhK9XngXZl8Yka7F VtmDV+JhrV/j6jL06nHWv0qvL3jHnPEvB9jfc+o2GYj/i76xty+/rY6wLh03YjI1KQ IiTVtb8hFbVl3YncHAyB2BfGYzLSu8S3+nPbDfhk= Date: Mon, 14 Feb 2022 11:02:28 +0100 From: Greg Kroah-Hartman To: Lu Baolu Cc: Joerg Roedel , Alex Williamson , Bjorn Helgaas , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Dan Williams , rafael@kernel.org, Diana Craciun , Cornelia Huck , Eric Auger , Liu Yi L , Jacob jun Pan , Chaitanya Kulkarni , Stuart Yoder , Laurentiu Tudor , Thierry Reding , David Airlie , Daniel Vetter , Jonathan Hunter , Li Yang , Dmitry Osipenko , iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 02/14] driver core: Add dma_cleanup callback in bus_type Message-ID: References: <20220104015644.2294354-1-baolu.lu@linux.intel.com> <20220104015644.2294354-3-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220104015644.2294354-3-baolu.lu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 04, 2022 at 09:56:32AM +0800, Lu Baolu wrote: > The bus_type structure defines dma_configure() callback for bus drivers > to configure DMA on the devices. This adds the paired dma_cleanup() > callback and calls it during driver unbinding so that bus drivers can do > some cleanup work. > > One use case for this paired DMA callbacks is for the bus driver to check > for DMA ownership conflicts during driver binding, where multiple devices > belonging to a same IOMMU group (the minimum granularity of isolation and > protection) may be assigned to kernel drivers or user space respectively. > > Without this change, for example, the vfio driver has to listen to a bus > BOUND_DRIVER event and then BUG_ON() in case of dma ownership conflict. > This leads to bad user experience since careless driver binding operation > may crash the system if the admin overlooks the group restriction. Aside > from bad design, this leads to a security problem as a root user, even with > lockdown=integrity, can force the kernel to BUG. > > With this change, the bus driver could check and set the DMA ownership in > driver binding process and fail on ownership conflicts. The DMA ownership > should be released during driver unbinding. > > Signed-off-by: Lu Baolu Reviewed-by: Greg Kroah-Hartman