Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4612yba; Fri, 5 Apr 2019 00:28:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwm4MkkSXz8Xywz7gUcy3hhsApe0EWlflspK9B67EEgCM6jWMqNnpKkqTkHIPZwz15X3px X-Received: by 2002:a63:530e:: with SMTP id h14mr10402325pgb.136.1554449282590; Fri, 05 Apr 2019 00:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554449282; cv=none; d=google.com; s=arc-20160816; b=sDznWeyrnm5+Ym+NOiQpBV2jCsNpjQlLyGzlQJZ/XC3n4W9Ik+hvcbCxAOqmyD43iF EbpZg/sy+Kf3N98mrjL5WcPwUmV4CsPiA2VtTrHy10jhrztllyO7fb/ADAvuemZBHM/1 OrcK5D/ZurcYGwXO93GaolZxxmXr/wnJ+sbRx+wv9mVD7MxHQFtpMZeKog1WMQSKYXlN VIhjO1MoYto3NFm3FYtlfRX8QyYoIAEIUG/0QTk7bZYwafqSkG/zNveMHStCg1YsioHu 7dXXp+Q0k9IqWbquR4YLOnK1GPT+pcB1SLeXQQ5R/y7ssodWk3WAUmEKxHhuZumZU8Si +gmA== 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 :message-id:date:subject:cc:to:from; bh=33i4MqmSiBJNkHc+kFjjBcrzxr3prTtDPxOQD5lBHM4=; b=Jw/K5dBWFc6FKGfQU48L6x1CeP+Wm/hhQfDBLxKQ+YTJmBrLSiWCB5v+MV+a9Fls4v 6VIWOOF4UJmMd1Mc1AeoPL+KFVRqkncPxGDUPlY9WAmP5NhGc9QzXp2zfCwiP+VhYi5X 4IVF6RknATi4IVhWYCeBjHRsGFzlazytoMNfRu/OCMC0z5jJ1j8gdUoPcMni7dCtLYmD +Cr6t9OFKZ4nnlbJKhaITGkDZijlK6+0fowkSTABLKTYpGH41+sZl5N9lqYkSZkqn3bD XE31EIi6ESbvhhg35k710V8Zr7U0qKOFbNmelXq5yEmbxdO9dBGrGgD+6L5Uahx41tYZ T64w== 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 l8si13348593pfc.223.2019.04.05.00.27.47; Fri, 05 Apr 2019 00:28:02 -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 S1730045AbfDEH1H (ORCPT + 99 others); Fri, 5 Apr 2019 03:27:07 -0400 Received: from mga04.intel.com ([192.55.52.120]:29088 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726726AbfDEH1G (ORCPT ); Fri, 5 Apr 2019 03:27:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2019 00:27:06 -0700 X-IronPort-AV: E=Sophos;i="5.60,310,1549958400"; d="scan'208";a="131667186" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2019 00:27:03 -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] drm/i915: Use drm_dev_unplug() Date: Fri, 5 Apr 2019 09:26:57 +0200 Message-Id: <20190405072657.9997-1-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.20.1 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. Signed-off-by: Janusz Krzysztofik --- 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