Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3910086rwl; Mon, 27 Mar 2023 23:12:42 -0700 (PDT) X-Google-Smtp-Source: AKy350Zz0nQ1OKvYd9HyQSebKf44JWIFo5ElTtgBp+emcWoHsIVf75r7HBzCZQrYupNwt3dk76Zh X-Received: by 2002:aa7:c74d:0:b0:4ac:bbaa:867a with SMTP id c13-20020aa7c74d000000b004acbbaa867amr12550521eds.24.1679983961993; Mon, 27 Mar 2023 23:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679983961; cv=none; d=google.com; s=arc-20160816; b=Xo3EhpAq6mLAgXLPOaQMc5ORpsceFT9C7ZtKq3eREfWpVRmYnTD9y+a16qwVSuaG1w q5lw53r0SymSKSZGWWrt9lZ6VYJVx57WB8X8d52HhK4179gN4E5VhjQY7XZJKC+WHnqz KMghc1IZwCa4iv0K8mkI77YRubPrmndYVmkzN6zCDD7LUVP823v8CGJ6W3EjysEgAkkA 93ZTTwAWl5NC3H14vOvirGo1jIGWW0VCnO7c/4Xgc8srpB+ewr1GzAXpjvp2K0WBn3jA pXKLst48J9g4lKnW0aAxC1uInxpxsLyT0m9fJ8Gz1tpdvnRmBEno+CdaRhJGUx0Wdc7m SJnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=yJ7B6s2fD1koyla5RoVwvgTy2IgdJ0wqSahHRiARVgM=; b=EbuzQTC9EY97nP/hrNVp1Y3p9wvR8xFcDMBKDD6K2MNY6fz57R/Cw10nTUq2yy06PV 1GyGO6+xuNIAQl/q+KoeRaQsP81RLwa9/oBdnGO9m6hAoJehFehIFI7oGgmWEEHZWcsV 0ihsEP22NhC4DuEU2fyvucG4pqh/arcEMNqN7yQgwd8UzTw4pBdry2jVmuneLrnjU500 LNn8BnmXqYjraPA04rbo5kxBg0MdFjpIYrY4/ehXl+xs/NAPuMptKy/H1dYorXgZOwGE 7Vgk3r8t77WcbcyHFW2pUJDZrjdfndx6/qJtQ1nofo6WU4ia3aoG2IrP5DAhwvrV/Zoe t8rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FqAOZ5DL; 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 h3-20020a170906828300b008d6b51de6bcsi29357615ejx.32.2023.03.27.23.12.17; Mon, 27 Mar 2023 23:12:41 -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=FqAOZ5DL; 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 S231543AbjC1GED (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED,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 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