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 X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67766C433FE for ; Fri, 24 Sep 2021 13:00:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53DA76124C for ; Fri, 24 Sep 2021 13:00:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345250AbhIXNBl (ORCPT ); Fri, 24 Sep 2021 09:01:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:53310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345419AbhIXM7k (ORCPT ); Fri, 24 Sep 2021 08:59:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE2C361362; Fri, 24 Sep 2021 12:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632488008; bh=gvIjB8OOrrv5Z+DarVr6BPu4UxusQVTO8fpLctnqWHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MHM3ZIe0ii+HOe7jwk9DFaYuI2a8pykpuueJwGyhszVHwvTpcThuj8W+Xz+SnLHxL Zw2ksIJGZOtAMVXmZlfHGTbDz6Lw+lkMGxBtjmXBJJaJp7693asRrVoxVIBIKDITgS ekcGOFPDR8CoPkzfusCLBgoLBVl8wqf0mB3cQW8s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jacob Pan , Fenghua Yu , Lu Baolu , Joerg Roedel , Sasha Levin , Dave Jiang Subject: [PATCH 5.14 048/100] iommu/vt-d: Fix PASID leak in intel_svm_unbind_mm() Date: Fri, 24 Sep 2021 14:43:57 +0200 Message-Id: <20210924124343.053305848@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210924124341.214446495@linuxfoundation.org> References: <20210924124341.214446495@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Fenghua Yu [ Upstream commit a21518cb23a3c7d49bafcb59862fd389fd829d4b ] The mm->pasid will be used in intel_svm_free_pasid() after load_pasid() during unbinding mm. Clearing it in load_pasid() will cause PASID cannot be freed in intel_svm_free_pasid(). Additionally mm->pasid was updated already before load_pasid() during pasid allocation. No need to update it again in load_pasid() during binding mm. Don't update mm->pasid to avoid the issues in both binding mm and unbinding mm. Fixes: 4048377414162 ("iommu/vt-d: Use iommu_sva_alloc(free)_pasid() helpers") Reported-and-tested-by: Dave Jiang Co-developed-by: Jacob Pan Signed-off-by: Jacob Pan Signed-off-by: Fenghua Yu Link: https://lore.kernel.org/r/20210826215918.4073446-1-fenghua.yu@intel.com Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210828070622.2437559-2-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/intel/svm.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 4b9b3f35ba0e..ceeca633a5f9 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -516,9 +516,6 @@ static void load_pasid(struct mm_struct *mm, u32 pasid) { mutex_lock(&mm->context.lock); - /* Synchronize with READ_ONCE in update_pasid(). */ - smp_store_release(&mm->pasid, pasid); - /* Update PASID MSR on all CPUs running the mm's tasks. */ on_each_cpu_mask(mm_cpumask(mm), _load_pasid, NULL, true); -- 2.33.0