From patchwork Thu Sep 8 20:07:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nirmoy Das X-Patchwork-Id: 12970637 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2119C54EE9 for ; Thu, 8 Sep 2022 20:07:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD54A10E064; Thu, 8 Sep 2022 20:07:22 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id BAE2710E064 for ; Thu, 8 Sep 2022 20:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662667639; x=1694203639; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=CckStyMebEHsUAIZs+aXqi0IbL/BULQQ5dwyq2c0UcI=; b=gI/43c/tzqo720m+V9fkTs1lW0jlF8chOew5Rbpf0OFC3FYyu4IJYSri NHgj1eXs5EuM4DQ8c/nmYIyfH7ZUv1TzCcBQFdgONxg03XSxFagSAWcbk WeuwYfmMzSQsmPCIl5yVC00B/+2y8Dlv/U0aMYxjX1IVDkSWx3yMtAiL7 dsyyRUfS/EJJLxWERpINYDv9e80h1c5OTJCanYBvnN7PAn57Lu9sSMXOg BAH7X7yVIWBLR1h4pJu/QYDeQOfq6dZaTFNeIoiYYSjhUq2KuR2Y0rf4J hX93uSDrUPojDsLDNxAmrotqTtysvZ9lbZeJbwyAH80Y8jVmGv7Ic59QG A==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="284332840" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="284332840" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 13:07:19 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="683369645" Received: from nirmoyda-desk.igk.intel.com ([10.102.13.19]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 13:07:17 -0700 From: Nirmoy Das To: intel-gfx@lists.freedesktop.org Date: Thu, 8 Sep 2022 22:07:05 +0200 Message-Id: <20220908200706.25773-1-nirmoy.das@intel.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Organization: Intel Deutschland GmbH, Registered Address: Am Campeon 10, 85579 Neubiberg, Germany, Commercial Register: Amtsgericht Muenchen HRB 186928 Subject: [Intel-gfx] [PATCH 1/2] drm/i915: Fix a potential UAF at device unload X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: matthew.auld@intel.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" i915_gem_drain_freed_objects() might not be enough to free all the objects and RCU delayed work might get scheduled after the i915 device struct gets freed. Call i915_gem_drain_workqueue() to catch all RCU delayed work. Suggested-by: Chris Wilson Signed-off-by: Nirmoy Das Acked-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 0f49ec9d494a..e8a053eaaa89 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1254,7 +1254,7 @@ void i915_gem_init_early(struct drm_i915_private *dev_priv) void i915_gem_cleanup_early(struct drm_i915_private *dev_priv) { - i915_gem_drain_freed_objects(dev_priv); + i915_gem_drain_workqueue(dev_priv); GEM_BUG_ON(!llist_empty(&dev_priv->mm.free_list)); GEM_BUG_ON(atomic_read(&dev_priv->mm.free_count)); drm_WARN_ON(&dev_priv->drm, dev_priv->mm.shrink_count); From patchwork Thu Sep 8 20:07:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nirmoy Das X-Patchwork-Id: 12970638 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3A91C54EE9 for ; Thu, 8 Sep 2022 20:07:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B71110E59C; Thu, 8 Sep 2022 20:07:23 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7782410E064 for ; Thu, 8 Sep 2022 20:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662667640; x=1694203640; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=t4YzckH8BTqVLkL7QfedK6zJ/LcLRnUBnt18GjY0m1A=; b=X+/qnTnmnYEl5jbC/aYL96WdKt3GHOAQdrQxhNsyWUu3MAKMwRa3XX9m 0Kgb9d5BMNO2+ejsxjn5RH4GKJ+qBLLhmNuRN7WszS9Hrm4AJwz4LQ1F/ zRAdPVVXZ53Cr9H2MHVv9eAMLjytR02OjCdcbIUUdW02Un7dw09Hm7YAf PzK7+L9X3E8Hoy2JClQtZS92yoI2PUpce1hq/Gac7sd7ZdiF8fLtr/iH0 d+EWtjdk8J1c0XxUQUrYBRW5J+RmyPLFWG4LaPdFF7ajUeCBQHwUIZIuw MN+MX8WgP0C4F3/bMs4Xml4EM3bRbA7lq8PlVr4haHbIDKyiWBwQHfvkr Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="284332841" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="284332841" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 13:07:20 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="683369650" Received: from nirmoyda-desk.igk.intel.com ([10.102.13.19]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 13:07:19 -0700 From: Nirmoy Das To: intel-gfx@lists.freedesktop.org Date: Thu, 8 Sep 2022 22:07:06 +0200 Message-Id: <20220908200706.25773-2-nirmoy.das@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220908200706.25773-1-nirmoy.das@intel.com> References: <20220908200706.25773-1-nirmoy.das@intel.com> MIME-Version: 1.0 Organization: Intel Deutschland GmbH, Registered Address: Am Campeon 10, 85579 Neubiberg, Germany, Commercial Register: Amtsgericht Muenchen HRB 186928 Subject: [Intel-gfx] [PATCH 2/2] drm/i915: remove excessive i915_gem_drain_freed_objects X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: matthew.auld@intel.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" i915_gem_drain_workqueue() call i915_gem_drain_freed_objects() so no need to call that again. Signed-off-by: Nirmoy Das Reviewed-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_gem.c | 2 -- drivers/gpu/drm/i915/selftests/mock_gem_device.c | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index e8a053eaaa89..e16718d79533 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1217,8 +1217,6 @@ void i915_gem_driver_remove(struct drm_i915_private *dev_priv) /* Flush any outstanding unpin_work. */ i915_gem_drain_workqueue(dev_priv); - - i915_gem_drain_freed_objects(dev_priv); } void i915_gem_driver_release(struct drm_i915_private *dev_priv) diff --git a/drivers/gpu/drm/i915/selftests/mock_gem_device.c b/drivers/gpu/drm/i915/selftests/mock_gem_device.c index f5904e659ef2..5d02346c43a2 100644 --- a/drivers/gpu/drm/i915/selftests/mock_gem_device.c +++ b/drivers/gpu/drm/i915/selftests/mock_gem_device.c @@ -67,7 +67,6 @@ static void mock_device_release(struct drm_device *dev) intel_gt_driver_remove(to_gt(i915)); i915_gem_drain_workqueue(i915); - i915_gem_drain_freed_objects(i915); mock_fini_ggtt(to_gt(i915)->ggtt); destroy_workqueue(i915->wq);