Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp679676yba; Thu, 18 Apr 2019 07:53:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpiCqn1ndQV3V+jIvwLTYN7VfA5GkHCNKGY4WAJ8GzjpjBCLKe42iZEGvx+sJwJlXPS/LI X-Received: by 2002:a63:1043:: with SMTP id 3mr88682067pgq.283.1555599181001; Thu, 18 Apr 2019 07:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555599180; cv=none; d=google.com; s=arc-20160816; b=iUjzrlB98CqdEa5bLMC8i/q/FwIzDSDcWubTabrwH3sFbx24aAzYs1SCyiKrjuTw6j 93IcjzTt73+ohvJbJF2l9eHzG+IumwwCOPs/ByiSoTJXMfMw2QdIk7ipBsCKZQ60PG6/ E2sIwSGqzC1zHIN7xPJgkNQ+0vmSQcrak74KFpg0oZV/Gn48u/xsbGhlhld+Qvd6ip24 XKF2CupwyGfwfHN8hDw9a5qBpJsoAn3QZ7A8RY6mBUKzSOXgCZ4iDGbzL1h859IPZWPX icvfc3oDm4QCnpcHqniA7jv3WY8A1QFaArD6FKk/TxLRh5KSRmiZ6tQP9iuH+boF80E7 tjvA== 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=iTu7WSymvKSfi7itiIGDDutfbLrZk13C+phf/HouG/0=; b=on1ToSn/k0a4uCslEKx1AZx5rs7FWZHkBVJWZmGVtQoPJNZF4oWuZzOYnmn4AHjXbi iKsMum2K6LMOqHi4ZWpu0DxQ0Iev4R+kVe2cpO59+NsiRnkyF7k/8juXgalgtXDxuSjG a0/Zn8FKIIvp/NVrVQwCUeVdvOuFqBVJ2pRWUGzlfC47tUzDr9c6qHEZSDDaDa8m8XXg g/zXVJaWVlcHlSIc2Y8HI6/EkwIez8oc6ahG6KOQbZWXJsePJo90FDNcfgJjXn6Iq+Pv f3mbRKb8fiq3Wx9oDur+G19x+MxNe46BdxtICLR4UJkTfhcmLjdDXk3absNVnmVieuMK 0Hcw== 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 f6si2416739plf.90.2019.04.18.07.52.46; Thu, 18 Apr 2019 07:53:00 -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 S2389135AbfDROvk (ORCPT + 99 others); Thu, 18 Apr 2019 10:51:40 -0400 Received: from mga07.intel.com ([134.134.136.100]:23236 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733192AbfDROvk (ORCPT ); Thu, 18 Apr 2019 10:51:40 -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 orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Apr 2019 07:51:39 -0700 X-IronPort-AV: E=Sophos;i="5.60,366,1549958400"; d="scan'208";a="135450495" 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; 18 Apr 2019 07:51:36 -0700 From: Janusz Krzysztofik To: Jani Nikula , Joonas Lahtinen , 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@linux.intel.com, janusz.krzysztofik@intel.com, Daniel Vetter Subject: [PATCH v2 1/1] drm/i915: Use drm_dev_unplug() Date: Thu, 18 Apr 2019 16:51:23 +0200 Message-Id: <20190418145123.11085-2-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190418145123.11085-1-janusz.krzysztofik@linux.intel.com> References: <20190405130235.7707-1-janusz.krzysztofik@linux.intel.com> <155445268803.8259.16095445514284244974@skylake-alporthouse-com> <20190415093225.GZ2665@phenom.ffwll.local> <20190418145123.11085-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. Signed-off-by: Janusz Krzysztofik Reviewed-by: Chris Wilson Reviewed-by: Daniel Vetter --- 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