Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3667585pxb; Mon, 24 Jan 2022 14:54:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwJCjv///a9xeYLuRV2qXCxh7A+Jcc7U0vaIhK3/L2xUBWHNHXHwvmeFIUhR8+OxS6kdd1 X-Received: by 2002:a17:902:da90:b0:14b:4c2d:e202 with SMTP id j16-20020a170902da9000b0014b4c2de202mr6751410plx.96.1643064848348; Mon, 24 Jan 2022 14:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064848; cv=none; d=google.com; s=arc-20160816; b=mTqwj3XtLEURgfOEpcP4+/NIMviSwdrBsmuk3w00TopEjDwRTRF6kV81c3U50M4PaY KmnAPE//+rc2cY9ULbBKHl3WUdPHobONoQRtlOCTZKHhu+XDY+x0UqYg8RSeETFWQwAl V03yWESsDDZkFAnnQCYYNmopzFJ6wAcXfOm+3fo8vUKHcSnh7LbQfiqO4Yc7PsdEwEfB jB4Cfe5sB1H8sOxd/dji3VrrSNEpXIAWqeTV9wd0Fu+1CUOZqp9ejy68X5NbJs1Lm3uc OkbUiHbqY+4QyPdOwv3hHE0cGLBHrkOpn+2P4T2M4ZAGhFt4Q6+QfrexhnbZXOVmGXSP /Zsw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=acdQ2JlrHgDC/sJ2WXd30hCRJSeBtbctG8zedxbIweQ=; b=AKpM2EsrDeWKKl0csgODhxbmAD0dIHHXWGEowoXRDVoIp2CsTAxXEoz0zfuPd7FAB2 uKlSSpTNyFVuLwG9r+ynl6PpFwS3LMD3Xrl+uNkS5VlFkznFsfsiWBoa0EMTisoATC+b z3toISpNKkFbh28kU4E0MOktz3a0bmafW8cgoh4HUHezNb/FX5eWVAB+9mW6GPSu6h5J PLlGX1gzVmLgcBu926QCpHYvUP3XWtr3Lny1obctE24FcGeCp71XYVgEjPwGqImTh2bc 75rcD29k8E3G09F8rTM7aZFLCxX1nTn6NiSDJ2XRWbpQXxRD0QH8gKt/xlUZuAXG1Xox CtKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1A7Yx2o+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si562443pja.149.2022.01.24.14.53.55; Mon, 24 Jan 2022 14:54:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1A7Yx2o+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1839320AbiAXWuX (ORCPT + 99 others); Mon, 24 Jan 2022 17:50:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1572913AbiAXVmv (ORCPT ); Mon, 24 Jan 2022 16:42:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BBEEC0419E1; Mon, 24 Jan 2022 12:31:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 38D54B81253; Mon, 24 Jan 2022 20:31:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5116EC340E5; Mon, 24 Jan 2022 20:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056289; bh=jI6jJQ1Hx8HqSkH0QXPdw56p5o+wSAGat7bHGfPaK7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1A7Yx2o+CMfPmWYurRzAIP+5emPI9XjWss5z9BElm7HPqSgTQNpZfnaB67kUEp8Yy wwJezy/mgGeX0rlurzMIgH6XEcCWcmW1gOZmid0l9pDJg5TWR/3RYeKv/l75JDSWsb m3j9aUgvAVYdV5sA7JSEEj9VGBVS2p4p+8BWeoQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ashish Mhetre , Lu Baolu , Joerg Roedel , Sasha Levin Subject: [PATCH 5.15 402/846] iommu: Extend mutex lock scope in iommu_probe_device() Date: Mon, 24 Jan 2022 19:38:39 +0100 Message-Id: <20220124184114.828786411@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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: linux-kernel@vger.kernel.org From: Lu Baolu [ Upstream commit 556f99ac886635e8da15528995f06d1d7028cfca ] Extend the scope of holding group->mutex so that it can cover the default domain check/attachment and direct mappings of reserved regions. Cc: Ashish Mhetre Fixes: 211ff31b3d33b ("iommu: Fix race condition during default domain allocation") Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20211108061349.1985579-1-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 3303d707bab4b..f62fb6a58f109 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -287,11 +287,11 @@ int iommu_probe_device(struct device *dev) */ mutex_lock(&group->mutex); iommu_alloc_default_domain(group, dev); - mutex_unlock(&group->mutex); if (group->default_domain) { ret = __iommu_attach_device(group->default_domain, dev); if (ret) { + mutex_unlock(&group->mutex); iommu_group_put(group); goto err_release; } @@ -299,6 +299,7 @@ int iommu_probe_device(struct device *dev) iommu_create_device_direct_mappings(group, dev); + mutex_unlock(&group->mutex); iommu_group_put(group); if (ops->probe_finalize) -- 2.34.1