Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp186161rwl; Tue, 28 Mar 2023 23:41:11 -0700 (PDT) X-Google-Smtp-Source: AKy350YVt/oI4RLv0fMvu1oG/+7ngQN6MmCwMiyNG4x358MiT5M7c0mfhw81v75iMIsHJQytdTbL X-Received: by 2002:a17:906:ae53:b0:8b1:7ac6:3186 with SMTP id lf19-20020a170906ae5300b008b17ac63186mr18536835ejb.68.1680072071077; Tue, 28 Mar 2023 23:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680072071; cv=none; d=google.com; s=arc-20160816; b=wsh5cZ1vaApFVOXzta8x5FSANQEFjqWGq9fHqaKi4vm3b5jSCPBCVyultPHAaykAkM UbuICptTmtk6Xhb1gw9HI3Y7j3FTyslCMUgP+gd0pIzxPdU3TletB83eCoLnkAtDmZlK N7pDFpPaucfl1Gdxb5qLWh4Sjwukk5545KWQrlMZjgwOSlt8PqUwgBawjMYBJ3ThszGP VlCJoSf6/pozNuFzPFRfbQf+bbhmDgdewSOJn/MjrUsCj0HOTpjLd9uekCy+cTs+DsUV uE19f/O9D+dNbuMFVBTZMpHXSWg7Kq4NJ+0wVBTd7smDA0Lg1MO4guGSnEH++OooN+fY 2LwA== 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=w5Ae1KK1SGfCQpCSUDI3XcFC8qetV4WZKCANgMKA4SE=; b=kt1TbgxV+5SnTjlRtcotbH+wYRZHo0A6+ldWnUUOBOaV+W++GOsGPr03QyIkqrEBiv 6AA3qEpe63nXBLeJGvzuopAO6YirpVWSy4rXdY1wh2KxDihDOJ95egwC7e9p5XNu09pN wyvfBhttGysPuaTwoPDGHwx4YjS8OapAJ3iraV63CEMTrc+34vyRWy9uc1dHwpH0Xg5O Wb6iArfKOKohCp6LK1NOoj7iFfiaip3A+TRx2J1fu6ZZ8GbptVtXdBiu1Sf+3F5HayG4 8PZ+AC0YouT4oMfdPUAL4YyWNVIU1PI1y0updd1aq33Tf5875XFcFO3/yBFeSHE9WMg4 qF5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Y/3BIqAj"; 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 gs39-20020a1709072d2700b0093e7ed91726si15823216ejc.480.2023.03.28.23.40.45; Tue, 28 Mar 2023 23:41:11 -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="Y/3BIqAj"; 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 S229656AbjC2G2n (ORCPT + 99 others); Wed, 29 Mar 2023 02:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229646AbjC2G2k (ORCPT ); Wed, 29 Mar 2023 02:28:40 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BAE52D48; Tue, 28 Mar 2023 23:28:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680071318; x=1711607318; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=GuGO5s9eIj9SNxl6Nky1S/mvzj2pjVXEbD7qhLrdzag=; b=Y/3BIqAjhrsPs6kKBfHF3ippoUImXmnuLRTbn1RbKMJL+kEnbQq5ncmN 0aSMRGdpfBeCa6ygnGl6EFpgOriQSEe7C9HJldiAIvJuddibTbvDjvIgj GGm/awr3rLg13iklewU6/5Efsz3BOyEXrN3gwzCb238YElKcI0uNdyJ2H 9RckQNqtFgTyAJL1rK8tmUXaT5IeavvIvqnBaM23N8vkr5mfUywEwr/++ H66EylHczcmQQKI+aXDmiWAeez6C9SydlmCVZasC9ApFm2ZcLJX5glEms NFQuvg5Iwd+lmKk4gCV6T8plZZe1AE2V6By3TTinRJGIL9m11wlgfMM+0 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="340812838" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="340812838" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2023 23:28:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="808083289" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="808083289" Received: from allen-box.sh.intel.com (HELO [10.239.159.48]) ([10.239.159.48]) by orsmga004.jf.intel.com with ESMTP; 28 Mar 2023 23:28:33 -0700 Message-ID: <5d22bbeb-8630-9aa2-bc49-32b391ae577e@linux.intel.com> Date: Wed, 29 Mar 2023 14:28:51 +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, 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" Subject: Re: [PATCH v2 7/8] iommu: Export iommu_get_dma_domain Content-Language: en-US To: Jacob Pan References: <20230327232138.1490712-1-jacob.jun.pan@linux.intel.com> <20230327232138.1490712-8-jacob.jun.pan@linux.intel.com> <20230328084855.7b9cd981@jacob-builder> From: Baolu Lu In-Reply-To: <20230328084855.7b9cd981@jacob-builder> 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 11:48 PM, Jacob Pan wrote: > 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? Yes, of cause. Hence, the getting domain interfaces are only safe to be used in the driver of the device. Best regards, baolu