* [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes
@ 2026-03-09 22:44 Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 1/8] drm/rockchip: inno-hdmi: Switch to drmm_kzalloc() Cristian Ciocaltea
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Cristian Ciocaltea @ 2026-03-09 22:44 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Dmitry Baryshkov, Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
The first three patches in the series are fixes for use-after-free &
null-ptr-deref related issues found in dw_dp and inno-hdmi Rockchip DRM
drivers.
The following three patches provide a few minor improvements to dw_dp
and dw_hdmi_qp, while the remaining two address use-after-free and
memory allocation in DW DP core library.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
Changes in v2:
- Fixed conflicts while rebasing onto latest drm-misc-next
- Added two more patches:
* drm/bridge: synopsys: dw-dp: Unregister AUX channel on bridge detach
* drm/bridge: synopsys: dw-dp: Drop useless memory allocation
- Link to v1: https://lore.kernel.org/r/20260122-drm-rk-fixes-v1-0-3942f185750e@collabora.com
---
Cristian Ciocaltea (8):
drm/rockchip: inno-hdmi: Switch to drmm_kzalloc()
drm/rockchip: dw_dp: Switch to drmm_kzalloc()
drm/rockchip: dw_dp: Fix null-ptr-deref in dw_dp_remove()
drm/rockchip: dw_dp: Simplify error handling
drm/rockchip: dw_dp: Drop unnecessary #include
drm/rockchip: dw_hdmi_qp: Switch to drmm_encoder_init()
drm/bridge: synopsys: dw-dp: Unregister AUX channel on bridge detach
drm/bridge: synopsys: dw-dp: Drop useless memory allocation
drivers/gpu/drm/bridge/synopsys/dw-dp.c | 12 ++++++---
drivers/gpu/drm/rockchip/dw_dp-rockchip.c | 35 ++++++++++----------------
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 13 +++++-----
drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c | 3 ++-
4 files changed, 29 insertions(+), 34 deletions(-)
---
base-commit: bfb18fd193e2413f02ad934e46887f415f0ce4ec
change-id: 20260122-drm-rk-fixes-a7622c71553e
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/8] drm/rockchip: inno-hdmi: Switch to drmm_kzalloc()
2026-03-09 22:44 [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Cristian Ciocaltea
@ 2026-03-09 22:44 ` Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 2/8] drm/rockchip: dw_dp: " Cristian Ciocaltea
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Cristian Ciocaltea @ 2026-03-09 22:44 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Dmitry Baryshkov, Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
Driver makes use of drmm_encoder_init() to initialize the encoder and
automatically handle the cleanup by registering drm_encoder_cleanup()
with drmm_add_action().
However, the internal structure containing the encoder part gets
allocated with devm_kzalloc(), which happens while component_bind_all()
is being called from Rockchip DRM driver. The component framework
further ensures it is deallocated as part of releasing all the resources
claimed during bind, which is triggered from component_unbind_all().
When the reference to the DRM device gets eventually dropped via
drm_dev_put() in rockchip_drm_unbind(), drmm_encoder_alloc_release()
attempts to access the now released encoder structure, leading to
use-after-free.
Ensure driver's internal structure is still reachable on encoder cleanup
by switching from a device-managed allocation to a drm-managed one.
Fixes: 969325a2597e ("drm/rockchip: inno-hdmi: Convert to drm bridge")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c
index 97c20500f790..28e6fb09aae7 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c
@@ -14,6 +14,7 @@
#include <drm/bridge/inno_hdmi.h>
#include <drm/drm_bridge_connector.h>
+#include <drm/drm_managed.h>
#include <drm/drm_of.h>
#include "rockchip_drm_drv.h"
@@ -90,7 +91,7 @@ static int inno_hdmi_rockchip_bind(struct device *dev, struct device *master, vo
const struct inno_hdmi_plat_data *plat_data;
int ret;
- hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
+ hdmi = drmm_kzalloc(drm, sizeof(*hdmi), GFP_KERNEL);
if (!hdmi)
return -ENOMEM;
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 2/8] drm/rockchip: dw_dp: Switch to drmm_kzalloc()
2026-03-09 22:44 [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 1/8] drm/rockchip: inno-hdmi: Switch to drmm_kzalloc() Cristian Ciocaltea
@ 2026-03-09 22:44 ` Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 3/8] drm/rockchip: dw_dp: Fix null-ptr-deref in dw_dp_remove() Cristian Ciocaltea
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Cristian Ciocaltea @ 2026-03-09 22:44 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Dmitry Baryshkov, Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
Driver makes use of drmm_encoder_init() to initialize the encoder and
automatically handle the cleanup by registering drm_encoder_cleanup()
with drmm_add_action().
However, the internal structure containing the encoder part gets
allocated with devm_kzalloc(), which happens while component_bind_all()
is being called from Rockchip DRM driver. The component framework
further ensures it is deallocated as part of releasing all the resources
claimed during bind, which is triggered from component_unbind_all().
When the reference to the DRM device gets eventually dropped via
drm_dev_put() in rockchip_drm_unbind(), drmm_encoder_alloc_release()
attempts to access the now released encoder structure, leading to
use-after-free.
Ensure driver's internal structure is still reachable on encoder cleanup
by switching from a device-managed allocation to a drm-managed one.
Fixes: d68ba7bac955 ("drm/rockchip: Add RK3588 DPTX output support")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/rockchip/dw_dp-rockchip.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
index dac3d202971e..532af476d250 100644
--- a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
@@ -13,6 +13,7 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_bridge_connector.h>
+#include <drm/drm_managed.h>
#include <drm/drm_of.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
@@ -82,7 +83,7 @@ static int dw_dp_rockchip_bind(struct device *dev, struct device *master, void *
struct drm_connector *connector;
int ret;
- dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
+ dp = drmm_kzalloc(drm_dev, sizeof(*dp), GFP_KERNEL);
if (!dp)
return -ENOMEM;
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 3/8] drm/rockchip: dw_dp: Fix null-ptr-deref in dw_dp_remove()
2026-03-09 22:44 [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 1/8] drm/rockchip: inno-hdmi: Switch to drmm_kzalloc() Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 2/8] drm/rockchip: dw_dp: " Cristian Ciocaltea
@ 2026-03-09 22:44 ` Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 4/8] drm/rockchip: dw_dp: Simplify error handling Cristian Ciocaltea
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Cristian Ciocaltea @ 2026-03-09 22:44 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Dmitry Baryshkov, Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
Attempting to access driver data in the platform driver ->remove()
callback may lead to a null pointer dereference since there is no
guaranty that the component ->bind() callback invoking
platform_set_drvdata() was executed.
A common scenario is when Rockchip DRM driver didn't manage to run
component_bind_all() because of an (unrelated) error causing early
return from rockchip_drm_bind().
Drop the unnecessary call to platform_get_drvdata() and, instead,
reference the target device structure via platform_device.
Fixes: d68ba7bac955 ("drm/rockchip: Add RK3588 DPTX output support")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/rockchip/dw_dp-rockchip.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
index 532af476d250..8945a245398c 100644
--- a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
@@ -133,9 +133,7 @@ static int dw_dp_probe(struct platform_device *pdev)
static void dw_dp_remove(struct platform_device *pdev)
{
- struct rockchip_dw_dp *dp = platform_get_drvdata(pdev);
-
- component_del(dp->dev, &dw_dp_rockchip_component_ops);
+ component_del(&pdev->dev, &dw_dp_rockchip_component_ops);
}
static const struct dw_dp_plat_data rk3588_dp_plat_data = {
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 4/8] drm/rockchip: dw_dp: Simplify error handling
2026-03-09 22:44 [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Cristian Ciocaltea
` (2 preceding siblings ...)
2026-03-09 22:44 ` [PATCH v2 3/8] drm/rockchip: dw_dp: Fix null-ptr-deref in dw_dp_remove() Cristian Ciocaltea
@ 2026-03-09 22:44 ` Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 5/8] drm/rockchip: dw_dp: Drop unnecessary #include Cristian Ciocaltea
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Cristian Ciocaltea @ 2026-03-09 22:44 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Dmitry Baryshkov, Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
Make the code a bit more compact by getting rid of the superfluous
assignments around PTR_ERR().
While at it, also drop dev assignment in dw_dp_probe().
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/rockchip/dw_dp-rockchip.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
index 8945a245398c..fafefee8370d 100644
--- a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
@@ -104,20 +104,15 @@ static int dw_dp_rockchip_bind(struct device *dev, struct device *master, void *
drm_encoder_helper_add(encoder, &dw_dp_encoder_helper_funcs);
dp->base = dw_dp_bind(dev, encoder, plat_data);
- if (IS_ERR(dp->base)) {
- ret = PTR_ERR(dp->base);
- return ret;
- }
+ if (IS_ERR(dp->base))
+ return PTR_ERR(dp->base);
connector = drm_bridge_connector_init(drm_dev, encoder);
- if (IS_ERR(connector)) {
- ret = PTR_ERR(connector);
- return dev_err_probe(dev, ret, "Failed to init bridge connector");
- }
+ if (IS_ERR(connector))
+ return dev_err_probe(dev, PTR_ERR(connector),
+ "Failed to init bridge connector");
- drm_connector_attach_encoder(connector, encoder);
-
- return 0;
+ return drm_connector_attach_encoder(connector, encoder);
}
static const struct component_ops dw_dp_rockchip_component_ops = {
@@ -126,9 +121,7 @@ static const struct component_ops dw_dp_rockchip_component_ops = {
static int dw_dp_probe(struct platform_device *pdev)
{
- struct device *dev = &pdev->dev;
-
- return component_add(dev, &dw_dp_rockchip_component_ops);
+ return component_add(&pdev->dev, &dw_dp_rockchip_component_ops);
}
static void dw_dp_remove(struct platform_device *pdev)
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 5/8] drm/rockchip: dw_dp: Drop unnecessary #include
2026-03-09 22:44 [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Cristian Ciocaltea
` (3 preceding siblings ...)
2026-03-09 22:44 ` [PATCH v2 4/8] drm/rockchip: dw_dp: Simplify error handling Cristian Ciocaltea
@ 2026-03-09 22:44 ` Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 6/8] drm/rockchip: dw_hdmi_qp: Switch to drmm_encoder_init() Cristian Ciocaltea
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Cristian Ciocaltea @ 2026-03-09 22:44 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Dmitry Baryshkov, Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
Included header "rockchip_drm_vop.h" is not directly used, drop it.
While at it, ensure #include directives are ordered alphabetically.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/rockchip/dw_dp-rockchip.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
index fafefee8370d..22c0911f1896 100644
--- a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c
@@ -7,8 +7,11 @@
*/
#include <linux/component.h>
+#include <linux/media-bus-format.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
+#include <linux/videodev2.h>
+
#include <drm/bridge/dw_dp.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
@@ -19,11 +22,7 @@
#include <drm/drm_probe_helper.h>
#include <drm/drm_simple_kms_helper.h>
-#include <linux/media-bus-format.h>
-#include <linux/videodev2.h>
-
#include "rockchip_drm_drv.h"
-#include "rockchip_drm_vop.h"
struct rockchip_dw_dp {
struct dw_dp *base;
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 6/8] drm/rockchip: dw_hdmi_qp: Switch to drmm_encoder_init()
2026-03-09 22:44 [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Cristian Ciocaltea
` (4 preceding siblings ...)
2026-03-09 22:44 ` [PATCH v2 5/8] drm/rockchip: dw_dp: Drop unnecessary #include Cristian Ciocaltea
@ 2026-03-09 22:44 ` Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 7/8] drm/bridge: synopsys: dw-dp: Unregister AUX channel on bridge detach Cristian Ciocaltea
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Cristian Ciocaltea @ 2026-03-09 22:44 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Dmitry Baryshkov, Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
Simplify encoder initialization and cleanup by making use of
drmm_encoder_init(), which takes care of registering
drm_encoder_cleanup() with drmm_add_action().
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
index 1a09bcc96c3e..c78db7f8ab6c 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
@@ -21,6 +21,7 @@
#include <drm/bridge/dw_hdmi_qp.h>
#include <drm/display/drm_hdmi_helper.h>
#include <drm/drm_bridge_connector.h>
+#include <drm/drm_managed.h>
#include <drm/drm_of.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_simple_kms_helper.h>
@@ -477,7 +478,7 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,
if (!pdev->dev.of_node)
return -ENODEV;
- hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
+ hdmi = drmm_kzalloc(drm, sizeof(*hdmi), GFP_KERNEL);
if (!hdmi)
return -ENOMEM;
@@ -586,16 +587,16 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,
return ret;
drm_encoder_helper_add(encoder, &dw_hdmi_qp_rockchip_encoder_helper_funcs);
- drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);
+ ret = drmm_encoder_init(drm, encoder, NULL, DRM_MODE_ENCODER_TMDS, NULL);
+ if (ret)
+ return dev_err_probe(hdmi->dev, ret, "Failed to init encoder");
platform_set_drvdata(pdev, hdmi);
hdmi->hdmi = dw_hdmi_qp_bind(pdev, encoder, &plat_data);
- if (IS_ERR(hdmi->hdmi)) {
- drm_encoder_cleanup(encoder);
+ if (IS_ERR(hdmi->hdmi))
return dev_err_probe(hdmi->dev, PTR_ERR(hdmi->hdmi),
"Failed to bind dw-hdmi-qp");
- }
connector = drm_bridge_connector_init(drm, encoder);
if (IS_ERR(connector))
@@ -612,8 +613,6 @@ static void dw_hdmi_qp_rockchip_unbind(struct device *dev,
struct rockchip_hdmi_qp *hdmi = dev_get_drvdata(dev);
cancel_delayed_work_sync(&hdmi->hpd_work);
-
- drm_encoder_cleanup(&hdmi->encoder.encoder);
}
static const struct component_ops dw_hdmi_qp_rockchip_ops = {
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 7/8] drm/bridge: synopsys: dw-dp: Unregister AUX channel on bridge detach
2026-03-09 22:44 [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Cristian Ciocaltea
` (5 preceding siblings ...)
2026-03-09 22:44 ` [PATCH v2 6/8] drm/rockchip: dw_hdmi_qp: Switch to drmm_encoder_init() Cristian Ciocaltea
@ 2026-03-09 22:44 ` Cristian Ciocaltea
2026-03-26 19:28 ` Heiko Stuebner
2026-03-09 22:44 ` [PATCH v2 8/8] drm/bridge: synopsys: dw-dp: Drop useless memory allocation Cristian Ciocaltea
2026-03-26 19:41 ` (subset) [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Heiko Stuebner
8 siblings, 1 reply; 12+ messages in thread
From: Cristian Ciocaltea @ 2026-03-09 22:44 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Dmitry Baryshkov, Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
The DisplayPort AUX channel gets initialized and registered during
dw_dp_bind(), but it is never unregistered, which may lead to resource
leaks and/or use-after-free:
[ 224.661371] BUG: KASAN: slab-use-after-free in device_is_dependent+0xe0/0x2b0
[ 224.662015] Read of size 8 at addr ffff00011aee8550 by task modprobe/658
...
[ 224.662796] device_is_dependent+0xe0/0x2b0
[ 224.662802] device_is_dependent+0x108/0x2b0
[ 224.662808] device_link_add+0x1f8/0x10b0
[ 224.662813] devm_of_phy_get_by_index+0x120/0x200
[ 224.662819] dw_dp_bind+0x34c/0xb10 [dw_dp]
[ 224.662830] dw_dp_rockchip_bind+0x194/0x250 [rockchipdrm]
[ 224.662864] component_bind_all+0x3a8/0x720
[ 224.662869] rockchip_drm_bind+0x120/0x390 [rockchipdrm]
[ 224.662899] try_to_bring_up_aggregate_device+0x76c/0x838
[ 224.662904] component_master_add_with_match+0x1f4/0x230
[ 224.662909] rockchip_drm_platform_probe+0x420/0x538 [rockchipdrm]
[ 224.662939] platform_probe+0xe8/0x168
[ 224.662945] really_probe+0x340/0x828
[ 224.662950] __driver_probe_device+0x2e0/0x350
[ 224.662954] driver_probe_device+0x80/0x140
[ 224.662959] __driver_attach+0x398/0x460
[ 224.662964] bus_for_each_dev+0xe0/0x198
[ 224.662968] driver_attach+0x50/0x68
[ 224.662972] bus_add_driver+0x2a0/0x4c0
[ 224.662977] driver_register+0x294/0x360
[ 224.662982] __platform_driver_register+0x7c/0x98
[ 224.662987] rockchip_drm_init+0xc4/0xff8 [rockchipdrm]
...
Unregister the AUX adapter on bridge detach.
Fixes: 86eecc3a9c2e ("drm/bridge: synopsys: Add DW DPTX Controller support library")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/bridge/synopsys/dw-dp.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
index e7bef9150f6a..8d02f047693a 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
@@ -1751,6 +1751,13 @@ static const struct drm_edid *dw_dp_bridge_edid_read(struct drm_bridge *bridge,
return edid;
}
+static void dw_dp_bridge_detach(struct drm_bridge *bridge)
+{
+ struct dw_dp *dp = bridge_to_dp(bridge);
+
+ drm_dp_aux_unregister(&dp->aux);
+}
+
static u32 *dw_dp_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
struct drm_bridge_state *bridge_state,
struct drm_crtc_state *crtc_state,
@@ -1824,6 +1831,7 @@ static const struct drm_bridge_funcs dw_dp_bridge_funcs = {
.atomic_disable = dw_dp_bridge_atomic_disable,
.detect = dw_dp_bridge_detect,
.edid_read = dw_dp_bridge_edid_read,
+ .detach = dw_dp_bridge_detach,
};
static int dw_dp_link_retrain(struct dw_dp *dp)
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 8/8] drm/bridge: synopsys: dw-dp: Drop useless memory allocation
2026-03-09 22:44 [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Cristian Ciocaltea
` (6 preceding siblings ...)
2026-03-09 22:44 ` [PATCH v2 7/8] drm/bridge: synopsys: dw-dp: Unregister AUX channel on bridge detach Cristian Ciocaltea
@ 2026-03-09 22:44 ` Cristian Ciocaltea
2026-03-26 19:41 ` (subset) [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Heiko Stuebner
8 siblings, 0 replies; 12+ messages in thread
From: Cristian Ciocaltea @ 2026-03-09 22:44 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Dmitry Baryshkov, Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
The bridge gets allocated and initialized implicitly via the
devm_drm_bridge_alloc() helper in dw_dp_bind(). However, this is
preceded by an explicit allocation for the same dw_dp struct, which is
never used anywhere as the return from devm_kzalloc() gets immediately
overwritten by the aforementioned helper.
Get rid of the unnecessary and confusing memory allocation.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/bridge/synopsys/dw-dp.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
index 8d02f047693a..9e7ace6be3a0 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
@@ -1977,10 +1977,6 @@ struct dw_dp *dw_dp_bind(struct device *dev, struct drm_encoder *encoder,
void __iomem *res;
int ret;
- dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
- if (!dp)
- return ERR_PTR(-ENOMEM);
-
dp = devm_drm_bridge_alloc(dev, struct dw_dp, bridge, &dw_dp_bridge_funcs);
if (IS_ERR(dp))
return ERR_CAST(dp);
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 7/8] drm/bridge: synopsys: dw-dp: Unregister AUX channel on bridge detach
2026-03-09 22:44 ` [PATCH v2 7/8] drm/bridge: synopsys: dw-dp: Unregister AUX channel on bridge detach Cristian Ciocaltea
@ 2026-03-26 19:28 ` Heiko Stuebner
2026-03-27 1:08 ` Cristian Ciocaltea
0 siblings, 1 reply; 12+ messages in thread
From: Heiko Stuebner @ 2026-03-26 19:28 UTC (permalink / raw)
To: Sandy Huang, Andy Yan, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dmitry Baryshkov,
Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Cristian Ciocaltea
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
Am Montag, 9. März 2026, 23:44:35 Mitteleuropäische Normalzeit schrieb Cristian Ciocaltea:
> The DisplayPort AUX channel gets initialized and registered during
> dw_dp_bind(), but it is never unregistered, which may lead to resource
> leaks and/or use-after-free:
>
> [ 224.661371] BUG: KASAN: slab-use-after-free in device_is_dependent+0xe0/0x2b0
> [ 224.662015] Read of size 8 at addr ffff00011aee8550 by task modprobe/658
> ...
> [ 224.662796] device_is_dependent+0xe0/0x2b0
> [ 224.662802] device_is_dependent+0x108/0x2b0
> [ 224.662808] device_link_add+0x1f8/0x10b0
> [ 224.662813] devm_of_phy_get_by_index+0x120/0x200
> [ 224.662819] dw_dp_bind+0x34c/0xb10 [dw_dp]
> [ 224.662830] dw_dp_rockchip_bind+0x194/0x250 [rockchipdrm]
> [ 224.662864] component_bind_all+0x3a8/0x720
> [ 224.662869] rockchip_drm_bind+0x120/0x390 [rockchipdrm]
> [ 224.662899] try_to_bring_up_aggregate_device+0x76c/0x838
> [ 224.662904] component_master_add_with_match+0x1f4/0x230
> [ 224.662909] rockchip_drm_platform_probe+0x420/0x538 [rockchipdrm]
> [ 224.662939] platform_probe+0xe8/0x168
> [ 224.662945] really_probe+0x340/0x828
> [ 224.662950] __driver_probe_device+0x2e0/0x350
> [ 224.662954] driver_probe_device+0x80/0x140
> [ 224.662959] __driver_attach+0x398/0x460
> [ 224.662964] bus_for_each_dev+0xe0/0x198
> [ 224.662968] driver_attach+0x50/0x68
> [ 224.662972] bus_add_driver+0x2a0/0x4c0
> [ 224.662977] driver_register+0x294/0x360
> [ 224.662982] __platform_driver_register+0x7c/0x98
> [ 224.662987] rockchip_drm_init+0xc4/0xff8 [rockchipdrm]
> ...
>
> Unregister the AUX adapter on bridge detach.
that sounds sort of asymmetrical though. drm_bridge_funcs has attach and
detach callbacks and the component-framework also has bind and unbind
callbacks.
This might cause confusion later on I guess, especially as I don't know
if there could be a bridge attach, after the detach that unregisters the
aux adapter.
Looking at the AnalogixDP for example, it does the the register and
unregister in the bind/unbind callbacks of the core driver.
So I guess the in my eyes cleaner way would be to introduce a
dw_dp_unbind() function and put the aux unregister there?
At least that way, everything would be at the same "level".
Heiko
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: (subset) [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes
2026-03-09 22:44 [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Cristian Ciocaltea
` (7 preceding siblings ...)
2026-03-09 22:44 ` [PATCH v2 8/8] drm/bridge: synopsys: dw-dp: Drop useless memory allocation Cristian Ciocaltea
@ 2026-03-26 19:41 ` Heiko Stuebner
8 siblings, 0 replies; 12+ messages in thread
From: Heiko Stuebner @ 2026-03-26 19:41 UTC (permalink / raw)
To: Sandy Huang, Andy Yan, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dmitry Baryshkov,
Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Cristian Ciocaltea
Cc: Heiko Stuebner, kernel, dri-devel, linux-arm-kernel,
linux-rockchip, linux-kernel
On Tue, 10 Mar 2026 00:44:28 +0200, Cristian Ciocaltea wrote:
> The first three patches in the series are fixes for use-after-free &
> null-ptr-deref related issues found in dw_dp and inno-hdmi Rockchip DRM
> drivers.
>
> The following three patches provide a few minor improvements to dw_dp
> and dw_hdmi_qp, while the remaining two address use-after-free and
> memory allocation in DW DP core library.
>
> [...]
Applied, thanks!
[1/8] drm/rockchip: inno-hdmi: Switch to drmm_kzalloc()
commit: 3cc50e7f73fcf79f28660b9d91566b13cb62e520
[2/8] drm/rockchip: dw_dp: Switch to drmm_kzalloc()
commit: ed9da8d23020352ad24c528db09b5acdd78b81fd
[3/8] drm/rockchip: dw_dp: Fix null-ptr-deref in dw_dp_remove()
commit: 9456381d8b60bb7dd42f2f04afe5ee4ce6e0bc12
[4/8] drm/rockchip: dw_dp: Simplify error handling
commit: 26cb3e26efa7cc84289966cab871889f6ca93616
[5/8] drm/rockchip: dw_dp: Drop unnecessary #include
commit: 31a98842a11fcb52a2db9b1b498d5ac11793e35f
[6/8] drm/rockchip: dw_hdmi_qp: Switch to drmm_encoder_init()
commit: e1f7b7cbd74c6561944f5dda345dab59ad391acb
[8/8] drm/bridge: synopsys: dw-dp: Drop useless memory allocation
commit: 971a6d5d41315f3bfe1e1207f24da9a191c949ff
Best regards,
--
Heiko Stuebner <heiko@sntech.de>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 7/8] drm/bridge: synopsys: dw-dp: Unregister AUX channel on bridge detach
2026-03-26 19:28 ` Heiko Stuebner
@ 2026-03-27 1:08 ` Cristian Ciocaltea
0 siblings, 0 replies; 12+ messages in thread
From: Cristian Ciocaltea @ 2026-03-27 1:08 UTC (permalink / raw)
To: Heiko Stuebner, Sandy Huang, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Dmitry Baryshkov, Dmitry Baryshkov, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec
Cc: kernel, dri-devel, linux-arm-kernel, linux-rockchip, linux-kernel
Hello Heiko,
On 3/26/26 9:28 PM, Heiko Stuebner wrote:
> Am Montag, 9. März 2026, 23:44:35 Mitteleuropäische Normalzeit schrieb Cristian Ciocaltea:
>> The DisplayPort AUX channel gets initialized and registered during
>> dw_dp_bind(), but it is never unregistered, which may lead to resource
>> leaks and/or use-after-free:
>>
>> [ 224.661371] BUG: KASAN: slab-use-after-free in device_is_dependent+0xe0/0x2b0
>> [ 224.662015] Read of size 8 at addr ffff00011aee8550 by task modprobe/658
>> ...
>> [ 224.662796] device_is_dependent+0xe0/0x2b0
>> [ 224.662802] device_is_dependent+0x108/0x2b0
>> [ 224.662808] device_link_add+0x1f8/0x10b0
>> [ 224.662813] devm_of_phy_get_by_index+0x120/0x200
>> [ 224.662819] dw_dp_bind+0x34c/0xb10 [dw_dp]
>> [ 224.662830] dw_dp_rockchip_bind+0x194/0x250 [rockchipdrm]
>> [ 224.662864] component_bind_all+0x3a8/0x720
>> [ 224.662869] rockchip_drm_bind+0x120/0x390 [rockchipdrm]
>> [ 224.662899] try_to_bring_up_aggregate_device+0x76c/0x838
>> [ 224.662904] component_master_add_with_match+0x1f4/0x230
>> [ 224.662909] rockchip_drm_platform_probe+0x420/0x538 [rockchipdrm]
>> [ 224.662939] platform_probe+0xe8/0x168
>> [ 224.662945] really_probe+0x340/0x828
>> [ 224.662950] __driver_probe_device+0x2e0/0x350
>> [ 224.662954] driver_probe_device+0x80/0x140
>> [ 224.662959] __driver_attach+0x398/0x460
>> [ 224.662964] bus_for_each_dev+0xe0/0x198
>> [ 224.662968] driver_attach+0x50/0x68
>> [ 224.662972] bus_add_driver+0x2a0/0x4c0
>> [ 224.662977] driver_register+0x294/0x360
>> [ 224.662982] __platform_driver_register+0x7c/0x98
>> [ 224.662987] rockchip_drm_init+0xc4/0xff8 [rockchipdrm]
>> ...
>>
>> Unregister the AUX adapter on bridge detach.
>
> that sounds sort of asymmetrical though. drm_bridge_funcs has attach and
> detach callbacks and the component-framework also has bind and unbind
> callbacks.
>
> This might cause confusion later on I guess, especially as I don't know
> if there could be a bridge attach, after the detach that unregisters the
> aux adapter.
>
> Looking at the AnalogixDP for example, it does the the register and
> unregister in the bind/unbind callbacks of the core driver.
>
> So I guess the in my eyes cleaner way would be to introduce a
> dw_dp_unbind() function and put the aux unregister there?
>
> At least that way, everything would be at the same "level".
You are right. As a matter of fact exporting the *_unbind() in the library was
my first thought, but for some reason I went with the "auto" approach.
I've just handled this in v3 [1].
Thanks for reviewing and picking the rest of the patches!
Regards,
Cristian
[1] https://lore.kernel.org/all/20260327-drm-rk-fixes-v3-0-fd2e6900c08c@collabora.com/
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-03-27 1:08 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 22:44 [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 1/8] drm/rockchip: inno-hdmi: Switch to drmm_kzalloc() Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 2/8] drm/rockchip: dw_dp: " Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 3/8] drm/rockchip: dw_dp: Fix null-ptr-deref in dw_dp_remove() Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 4/8] drm/rockchip: dw_dp: Simplify error handling Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 5/8] drm/rockchip: dw_dp: Drop unnecessary #include Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 6/8] drm/rockchip: dw_hdmi_qp: Switch to drmm_encoder_init() Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 7/8] drm/bridge: synopsys: dw-dp: Unregister AUX channel on bridge detach Cristian Ciocaltea
2026-03-26 19:28 ` Heiko Stuebner
2026-03-27 1:08 ` Cristian Ciocaltea
2026-03-09 22:44 ` [PATCH v2 8/8] drm/bridge: synopsys: dw-dp: Drop useless memory allocation Cristian Ciocaltea
2026-03-26 19:41 ` (subset) [PATCH v2 0/8] Rockchip DRM use-after-free & null-ptr-deref fixes Heiko Stuebner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox