Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4592497rwl; Tue, 28 Mar 2023 08:48:16 -0700 (PDT) X-Google-Smtp-Source: AKy350aCGWblOoDfGIhcVkNaHbIKLi5MfR+8dWdEZm+4SprERAkfb8dIfBkxo+qRO7HLnEIEq4Mq X-Received: by 2002:a17:902:d48b:b0:1a1:d70f:712d with SMTP id c11-20020a170902d48b00b001a1d70f712dmr19773165plg.31.1680018496086; Tue, 28 Mar 2023 08:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680018496; cv=none; d=google.com; s=arc-20160816; b=i+pES8Eahhl2Wzqb1O1a2hM231Dnl2vzVeY4JxZbScBmKdRGLoJDjv+Q0L3tqUY5jz NyJNz8g0q2AxWG3+zo4MutNn1VQa9BrXaBRQC6CRxyzlk7lcGUylkHGYKKJUA+DRmnBH NoiYBdUADRiRnU4TQyD6tCKdit1yurQjWkquw68jazadWkNxDKZ99zBmFzuIhOJzFarz 60Sa8j3QDan1pzDF0G/LSVUtxIVg230+rVq5DbH1f9pdas0e+Wc3ZokQnnCf4bOSXwOo V7yxXdRREuS1v87j/bjusdYdLqW+cB8HUsxLgXQbVYnDFQie1yGENT3SfX2/JfVX7y/V 07og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=m+VucoUUYwEd26vYV7/D08a9m9t1U2eSEHvp87kjnSE=; b=XOqJH5xtDZq4UQIwqYIDdBNv476mxsrJ0IxwzZ1OnUIR8KeOIi+mHDEYfVzLkmCoZT V0dj8fgXXRSLsLplpssiRAs1BRQvqH3i7CRMLGyTIbm4QJuyX1VNnc5rQ+JJTQC+E6i2 hrhMzB+1uv+aY2d/t9z38ktPcMEKd0auI+D1i6aIi3LrpsP04wqBdmRUkwUQiCxJ8A8s wTST7P5M87P5BGSv3HJ/eUohKuYzmyHn10VLRxJqGMAsbYkjbbfdt7dpW7GPOrTmxkgK /5rnKWHhT4w8kGgUvA22STP6LyBFx1Wt7sHiw88Ey743JEvtR8/8pbzMa8RJ9r+erl8J QkTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H4c7xOuG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a170902f15100b0019a59c52fd3si27892119plb.508.2023.03.28.08.48.04; Tue, 28 Mar 2023 08:48:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H4c7xOuG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234042AbjC1Pqt (ORCPT + 99 others); Tue, 28 Mar 2023 11:46:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232809AbjC1Pqb (ORCPT ); Tue, 28 Mar 2023 11:46:31 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29E76D311; Tue, 28 Mar 2023 08:46:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680018366; x=1711554366; h=date:from:to:cc:subject:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aANfklT01Q50VoPynu4eI92dQQpk9aNu69RWvGsHYk8=; b=H4c7xOuG90nCeD10p/p27A5IteIcRDsaZIhTC2YQKwca+3jR1KRlUraC Z3JCKP+Vo0R9uZ2qqGakgjjkBFDglsXESewg78V5F7ZL7EbJsygkv9STx +dM3Li2I3eGR7/ZSsXjZ+Mof/fseTTa38DQlM1w9rrlU2RMcpjI6akW8q LK1Ggh4LM5unxEZCLqRGElPNuQpEvtXDj6zoworBWbnuiEOH5zQ7gYBzC KAhGrmxyAeLHdegLEG5gcHfHJ6TJAJAuMm01WOa/DpfbfW+jS36vK90Lv rYOzCh5XejH6o/2EeTkUBlH47AwO7T8P8Gpp2fS9JbLdMfnMmaynov7UC A==; X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="368365970" X-IronPort-AV: E=Sophos;i="5.98,297,1673942400"; d="scan'208";a="368365970" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2023 08:44:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="753195774" X-IronPort-AV: E=Sophos;i="5.98,297,1673942400"; d="scan'208";a="753195774" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.24.100.114]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2023 08:44:52 -0700 Date: Tue, 28 Mar 2023 08:48:55 -0700 From: Jacob Pan To: Baolu Lu Cc: LKML , iommu@lists.linux.dev, Jason Gunthorpe , Joerg Roedel , dmaengine@vger.kernel.org, vkoul@kernel.org, Robin Murphy , Will Deacon , David Woodhouse , Raj Ashok , "Tian, Kevin" , Yi Liu , "Yu, Fenghua" , Dave Jiang , Tony Luck , "Zanussi, Tom" , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v2 7/8] iommu: Export iommu_get_dma_domain Message-ID: <20230328084855.7b9cd981@jacob-builder> In-Reply-To: References: <20230327232138.1490712-1-jacob.jun.pan@linux.intel.com> <20230327232138.1490712-8-jacob.jun.pan@linux.intel.com> Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Baolu, On Tue, 28 Mar 2023 14:04:15 +0800, Baolu Lu wrote: > On 3/28/23 7:21 AM, Jacob Pan wrote: > > Devices that use ENQCMDS to submit work needs to retrieve its DMA > > domain. It can then attach PASID to the DMA domain for shared mapping > > (with RID) established by DMA API. > > > > Signed-off-by: Jacob Pan > > --- > > drivers/iommu/iommu.c | 1 + > > include/linux/iommu.h | 5 +++++ > > 2 files changed, 6 insertions(+) > > > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > > index 10db680acaed..c51d343a75d2 100644 > > --- a/drivers/iommu/iommu.c > > +++ b/drivers/iommu/iommu.c > > @@ -2118,6 +2118,7 @@ struct iommu_domain *iommu_get_dma_domain(struct > > device *dev) { > > return dev->iommu_group->default_domain; > > } > > +EXPORT_SYMBOL_GPL(iommu_get_dma_domain); > > Directly exporting this function for external use seems unsafe. If the > caller is the kernel driver for this device, it's fine because default > domain remains unchanged during the life cycle of the driver. Otherwise, > using this function may cause UAF. Keep in mind that group's default > domain could be changed through sysfs. don't you have to unload the driver? > However, iommu_get_domain_for_dev() has already done so and has been > exported. Maybe I'm worried too much. :-) > > Best regards, > baolu Thanks, Jacob