From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
Sean Paul <sean@poorly.run>,
Daniel Vetter <daniel.vetter@intel.com>,
Sasha Levin <sashal@kernel.org>,
dri-devel@lists.freedesktop.org
Subject: [PATCH AUTOSEL 4.19 03/50] drm/kms: Catch mode_object lifetime errors
Date: Tue, 24 Sep 2019 12:48:00 -0400 [thread overview]
Message-ID: <20190924164847.27780-3-sashal@kernel.org> (raw)
In-Reply-To: <20190924164847.27780-1-sashal@kernel.org>
From: Daniel Vetter <daniel.vetter@ffwll.ch>
[ Upstream commit 4f5368b5541a902f6596558b05f5c21a9770dd32 ]
Only dynamic mode objects, i.e. those which are refcounted and have a free
callback, can be added while the overall drm_device is visible to
userspace. All others must be added before drm_dev_register and
removed after drm_dev_unregister.
Small issue around drivers still using the load/unload callbacks, we
need to make sure we set dev->registered so that load/unload code in
these callbacks doesn't trigger false warnings. Only a small
adjustement in drm_dev_register was needed.
Motivated by some irc discussions about object ids of dynamic objects
like blobs become invalid, and me going on a bit an audit spree.
Reviewed-by: Sean Paul <sean@poorly.run>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190614061723.1173-1-daniel.vetter@ffwll.ch
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/drm_drv.c | 4 ++--
drivers/gpu/drm/drm_mode_object.c | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index d8ae4ca129c70..1df30ef9f455a 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -810,14 +810,14 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
if (ret)
goto err_minors;
- dev->registered = true;
-
if (dev->driver->load) {
ret = dev->driver->load(dev, flags);
if (ret)
goto err_minors;
}
+ dev->registered = true;
+
if (drm_core_check_feature(dev, DRIVER_MODESET))
drm_modeset_register_all(dev);
diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
index 57cc9aa6683a0..30bf0d08dbf2f 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -37,6 +37,8 @@ int __drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj,
{
int ret;
+ WARN_ON(dev->registered && !obj_free_cb);
+
mutex_lock(&dev->mode_config.idr_mutex);
ret = idr_alloc(&dev->mode_config.crtc_idr, register_obj ? obj : NULL, 1, 0, GFP_KERNEL);
if (ret >= 0) {
@@ -96,6 +98,8 @@ void drm_mode_object_register(struct drm_device *dev,
void drm_mode_object_unregister(struct drm_device *dev,
struct drm_mode_object *object)
{
+ WARN_ON(dev->registered && !object->free_cb);
+
mutex_lock(&dev->mode_config.idr_mutex);
if (object->id) {
idr_remove(&dev->mode_config.crtc_idr, object->id);
--
2.20.1
next prev parent reply other threads:[~2019-09-24 16:57 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-24 16:47 [PATCH AUTOSEL 4.19 01/50] drm/bridge: tc358767: Increase AUX transfer length limit Sasha Levin
2019-09-24 16:47 ` [PATCH AUTOSEL 4.19 02/50] drm/bridge: adv7511: Attach to DSI host at probe time Sasha Levin
2019-09-24 16:48 ` Sasha Levin [this message]
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 04/50] drm/panel: simple: fix AUO g185han01 horizontal blanking Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 05/50] video: ssd1307fb: Start page range at page_offset Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 06/50] drm/stm: attach gem fence to atomic state Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 07/50] drm/panel: check failure cases in the probe func Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 08/50] drm/rockchip: Check for fast link training before enabling psr Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 09/50] drm/radeon: Fix EEH during kexec Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 10/50] gpu: drm: radeon: Fix a possible null-pointer dereference in radeon_connector_set_property() Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 11/50] PCI: rpaphp: Avoid a sometimes-uninitialized warning Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 12/50] ipmi_si: Only schedule continuously in the thread in maintenance mode Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 13/50] clk: qoriq: Fix -Wunused-const-variable Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 14/50] clk: sunxi-ng: v3s: add missing clock slices for MMC2 module clocks Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 15/50] drm/amd/display: fix issue where 252-255 values are clipped Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 16/50] drm/amd/display: reprogram VM config when system resume Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 17/50] powerpc/powernv/ioda2: Allocate TCE table levels on demand for default DMA window Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 18/50] drm/amd/powerplay/smu7: enforce minimal VBITimeout (v2) Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 19/50] clk: actions: Don't reference clk_init_data after registration Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 20/50] clk: sirf: " Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 21/50] clk: sprd: " Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 22/50] clk: zx296718: " Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 23/50] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 24/50] powerpc/rtas: use device model APIs and serialization during LPM Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 25/50] powerpc/futex: Fix warning: 'oldval' may be used uninitialized in this function Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 26/50] powerpc/64s/radix: Remove redundant pfn_pte bitop, add VM_BUG_ON Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 27/50] powerpc/pseries/mobility: use cond_resched when updating device tree Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 28/50] pinctrl: tegra: Fix write barrier placement in pmx_writel Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 29/50] powerpc/eeh: Clear stale EEH_DEV_NO_HANDLER flag Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 30/50] vfio_pci: Restore original state on release Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 31/50] drm/nouveau/volt: Fix for some cards having 0 maximum voltage Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 32/50] pinctrl: amd: disable spurious-firing GPIO IRQs Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 33/50] clk: renesas: mstp: Set GENPD_FLAG_ALWAYS_ON for clock domain Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 34/50] clk: renesas: cpg-mssr: " Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 35/50] drm/amd/display: support spdif Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 36/50] drm/amdgpu/si: fix ASIC tests Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 37/50] powerpc/64s/exception: machine check use correct cfar for late handler Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 38/50] pstore: fs superblock limits Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 39/50] powerpc/imc: Dont create debugfs files for cpu-less nodes Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 40/50] clk: qcom: gcc-sdm845: Use floor ops for sdcc clks Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 41/50] powerpc/pseries: correctly track irq state in default idle Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 42/50] pinctrl: meson-gxbb: Fix wrong pinning definition for uart_c Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 43/50] arm64: fix unreachable code issue with cmpxchg Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 44/50] clk: at91: select parent if main oscillator or bypass is enabled Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 45/50] powerpc: dump kernel log before carrying out fadump or kdump Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 46/50] mbox: qcom: add APCS child device for QCS404 Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 47/50] clk: sprd: add missing kfree Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 48/50] scsi: core: Reduce memory required for SCSI logging Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 49/50] dma-buf/sw_sync: Synchronize signal vs syncpt free Sasha Levin
2019-09-24 16:48 ` [PATCH AUTOSEL 4.19 50/50] ext4: fix potential use after free after remounting with noblock_validity Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190924164847.27780-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sean@poorly.run \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).