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 47760C76196 for ; Tue, 28 Mar 2023 06:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230468AbjC1GED (ORCPT ); Tue, 28 Mar 2023 02:04:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229968AbjC1GEC (ORCPT ); Tue, 28 Mar 2023 02:04:02 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13A02DC; Mon, 27 Mar 2023 23:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679983442; x=1711519442; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=vnpTrkgWOEL/GwwdpC+uOT5gFwIGgE12DtT51MDVw6A=; b=FqAOZ5DLZ7lltQVTjEtMqlwWLDA2pRJrpozoHfiHo4ZQhaXx9yppQKaE VSAuk8WJzX7ht3B2VDwRrgdLv5QW7aCkx3A0niMbct/hTh/dZxMM8RSZD 1eovkLxKBv9BYbnMGmqYK6aDa5R1L31KkOQD6ckpnKDF1Bv8jeZnAbWbQ TID8pQzPYEiyFlPxWxpAGEtn4lvZK4K3kHhXpeYSXHKnHD9rcAqdEyB9L 3ls7pa3SaJCipjIkcs6G2w+HU/coDZYzOuw2SZnZQPBBPgEoDAIbwXiE2 gjSwyjHL22JikEg1oq35anE7rPzFn8jatbJLVGjRV/W7E8upIOmTqaUc+ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10662"; a="426743807" X-IronPort-AV: E=Sophos;i="5.98,296,1673942400"; d="scan'208";a="426743807" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2023 23:04:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10662"; a="683758172" X-IronPort-AV: E=Sophos;i="5.98,296,1673942400"; d="scan'208";a="683758172" Received: from allen-box.sh.intel.com (HELO [10.239.159.48]) ([10.239.159.48]) by orsmga002.jf.intel.com with ESMTP; 27 Mar 2023 23:03:56 -0700 Message-ID: Date: Tue, 28 Mar 2023 14:04:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Cc: baolu.lu@linux.intel.com, Robin Murphy , Will Deacon , David Woodhouse , Raj Ashok , "Tian, Kevin" , Yi Liu , "Yu, Fenghua" , Dave Jiang , Tony Luck , "Zanussi, Tom" Subject: Re: [PATCH v2 7/8] iommu: Export iommu_get_dma_domain Content-Language: en-US To: Jacob Pan , LKML , iommu@lists.linux.dev, Jason Gunthorpe , Joerg Roedel , dmaengine@vger.kernel.org, vkoul@kernel.org References: <20230327232138.1490712-1-jacob.jun.pan@linux.intel.com> <20230327232138.1490712-8-jacob.jun.pan@linux.intel.com> From: Baolu Lu In-Reply-To: <20230327232138.1490712-8-jacob.jun.pan@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org 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. However, iommu_get_domain_for_dev() has already done so and has been exported. Maybe I'm worried too much. :-) Best regards, baolu