Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp248338yba; Fri, 5 Apr 2019 06:03:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8Vl7Qu9mQyVRqJ+sNZYQwpOS2aRhjy3BhXH1SecdU5vpzEfRycGxxS1RWDDrkAIvhH8T8 X-Received: by 2002:a17:902:7885:: with SMTP id q5mr13016285pll.12.1554469435478; Fri, 05 Apr 2019 06:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554469435; cv=none; d=google.com; s=arc-20160816; b=mBfKLx1nFDxJgpl8jNEhRezYWN5v53+MJAqsSIWrc1EeRK3gT2WhqtKx4DmzAuNXqS 9TbQMc+8EHRXLf2dL+HtdXZXDaoXROxceRX12up0adIbsRI2a78Hlw1FGqK+5cojwONc 6pMGZc+h+Fjiw0fEBShjfbdEi1VcmnXpUbKaYQSRaxcKnY8V0XJu1rbFYQswUE0aEtEj E2g2LMbmPS1+QleWIYgoL5w7z2S8x9O1A09fXiwQh1vQJYJab4UADu74+3XEeHvnBn9d n8GZwZiJQ9ChSjlsU7PMr5qQeXnT3EZOkjJljugSPiZ+0Y4NOzyOyj2zv2dBOabQT/DQ CwuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9A3POXpk4PxNEwRywd8n8DIrVuqWQBP6HXEG7g6poLM=; b=Zp0GvXNv71ZQeEG2GeE1i5cROI9HpWi4jsl+mdzxcD0M6J5GEWvKwlEJYYy7qsd9uM KMXQq9z+0Sh/L0ZJ+qS39DP6kmiG3JzBv1fNNe2EGu2ztb0sz/lAEzfo4ILg9WMouS4K gyPkhZVISvhP5JsdFvrlkNrPRgkmj4CtANd7yWGCf74r0Jw1kmAtpSuhHsSnjhOEi12e j3I23FVeE5aPHVR8XvDfYGkXVE1HftcvPuJP73I5x61M/o7UZ7nNw6VeOrK9ijLaBoWv Ypv9dCLAeYmXBgkS9nO0e+4Kf7Ay4Z87wi4KZ53xqFFGeK5GPt+ibhPLMt/yfFYAGw8Q YUXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18si16146214pls.319.2019.04.05.06.03.40; Fri, 05 Apr 2019 06:03:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730492AbfDENCz (ORCPT + 99 others); Fri, 5 Apr 2019 09:02:55 -0400 Received: from mga05.intel.com ([192.55.52.43]:19432 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbfDENCy (ORCPT ); Fri, 5 Apr 2019 09:02:54 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2019 06:02:54 -0700 X-IronPort-AV: E=Sophos;i="5.60,312,1549958400"; d="scan'208";a="148330384" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2019 06:02:51 -0700 From: Janusz Krzysztofik To: Joonas Lahtinen , Jani Nikula , Rodrigo Vivi Cc: David Airlie , Daniel Vetter , Chris Wilson , michal.wajdeczko@intel.com, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 1/2] drm/i915: Use drm_dev_unplug() Date: Fri, 5 Apr 2019 15:02:34 +0200 Message-Id: <20190405130235.7707-2-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190405130235.7707-1-janusz.krzysztofik@linux.intel.com> References: <20190405130235.7707-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Janusz Krzysztofik The driver does not currently support unbinding from a device which is in use. Since open file descriptors may still be pointing into kernel memory where the device structures used to be, entirely correct kernel panics protect the driver from being unbound as we should not be unbinding it before those dangling pointers have been made safe. According to the documentation found inside drivers/gpu/drm/drm_drv.c, drm_dev_unplug() should be used instead of drm_dev_unregister() in order to make a device inaccessible to users as soon as it is unpluged. Follow that advice to make those possibly dangling pointers safe, protected by DRM layer from a user who is otherwise left pointing into possibly reused kernel memory after the driver has been unbound from the device. Once done, also cancel inflight operations immediately by calling i915_gem_set_wedged(). Signed-off-by: Janusz Krzysztofik Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 9df65d386d11..66163378c481 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -1596,7 +1596,7 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv) i915_pmu_unregister(dev_priv); i915_teardown_sysfs(dev_priv); - drm_dev_unregister(&dev_priv->drm); + drm_dev_unplug(&dev_priv->drm); i915_gem_shrinker_unregister(dev_priv); } -- 2.20.1