* FAILED: patch "[PATCH] drm/nouveau/disp: fix use-after-free in error handling of" failed to apply to 6.1-stable tree
@ 2023-08-21 17:03 gregkh
2023-08-21 17:59 ` [PATCH 6.1.y] drm/nouveau/disp: fix use-after-free in error handling of nouveau_connector_create Karol Herbst
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2023-08-21 17:03 UTC (permalink / raw)
To: kherbst, lyude; +Cc: stable
The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 1b254b791d7b7dea6e8adc887fbbd51746d8bb27
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023082146-oxidation-equate-185a@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
1b254b791d7b ("drm/nouveau/disp: fix use-after-free in error handling of nouveau_connector_create")
773eb04d14a1 ("drm/nouveau/disp: expose conn event class")
ffd2664114c8 ("drm/nouveau/disp: expose head event class")
1d4dce284164 ("drm/nouveau/disp: switch vblank semaphore release to nvkm_event_ntfy")
f43e47c090dc ("drm/nouveau/nvkm: add a replacement for nvkm_notify")
361863ceab1e ("drm/nouveau/disp: move head scanoutpos method")
a2b7eadfef59 ("drm/nouveau/disp: add head class")
8c7d980da9ba ("drm/nouveau/disp: move DP MST payload config method")
8bb30c882334 ("drm/nouveau/disp: add method to trigger DP link retrain")
016dacb60e6d ("drm/nouveau/kms: pass event mask to hpd handler")
d62f8e982cb8 ("drm/nouveau/kms: switch hpd_lock from mutex to spinlock")
a62b74939063 ("drm/nouveau/disp: add method to control DPAUX pad power")
813443721331 ("drm/nouveau/disp: move DP link config into acquire")
a9f5d7721923 ("drm/nouveau/disp: move HDA ELD method")
f530bc60a30b ("drm/nouveau/disp: move HDMI config into acquire + infoframe methods")
9793083f1dd9 ("drm/nouveau/disp: move LVDS protocol information into acquire")
ea6143a86c67 ("drm/nouveau/disp: move and extend the role of outp acquire/release methods")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 1b254b791d7b7dea6e8adc887fbbd51746d8bb27 Mon Sep 17 00:00:00 2001
From: Karol Herbst <kherbst@redhat.com>
Date: Mon, 14 Aug 2023 16:49:32 +0200
Subject: [PATCH] drm/nouveau/disp: fix use-after-free in error handling of
nouveau_connector_create
We can't simply free the connector after calling drm_connector_init on it.
We need to clean up the drm side first.
It might not fix all regressions from commit 2b5d1c29f6c4
("drm/nouveau/disp: PIOR DP uses GPIO for HPD, not PMGR AUX interrupts"),
but at least it fixes a memory corruption in error handling related to
that commit.
Link: https://lore.kernel.org/lkml/20230806213107.GFZNARG6moWpFuSJ9W@fat_crate.local/
Fixes: 95983aea8003 ("drm/nouveau/disp: add connector class")
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230814144933.3956959-1-kherbst@redhat.com
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index a2e0033e8a26..622f6eb9a8bf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -1408,8 +1408,7 @@ nouveau_connector_create(struct drm_device *dev,
ret = nvif_conn_ctor(&disp->disp, nv_connector->base.name, nv_connector->index,
&nv_connector->conn);
if (ret) {
- kfree(nv_connector);
- return ERR_PTR(ret);
+ goto drm_conn_err;
}
ret = nvif_conn_event_ctor(&nv_connector->conn, "kmsHotplug",
@@ -1426,8 +1425,7 @@ nouveau_connector_create(struct drm_device *dev,
if (ret) {
nvif_event_dtor(&nv_connector->hpd);
nvif_conn_dtor(&nv_connector->conn);
- kfree(nv_connector);
- return ERR_PTR(ret);
+ goto drm_conn_err;
}
}
}
@@ -1475,4 +1473,9 @@ nouveau_connector_create(struct drm_device *dev,
drm_connector_register(connector);
return connector;
+
+drm_conn_err:
+ drm_connector_cleanup(connector);
+ kfree(nv_connector);
+ return ERR_PTR(ret);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6.1.y] drm/nouveau/disp: fix use-after-free in error handling of nouveau_connector_create
2023-08-21 17:03 FAILED: patch "[PATCH] drm/nouveau/disp: fix use-after-free in error handling of" failed to apply to 6.1-stable tree gregkh
@ 2023-08-21 17:59 ` Karol Herbst
2023-08-21 18:44 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Karol Herbst @ 2023-08-21 17:59 UTC (permalink / raw)
To: stable; +Cc: Karol Herbst, Lyude Paul
We can't simply free the connector after calling drm_connector_init on it.
We need to clean up the drm side first.
It might not fix all regressions from commit 2b5d1c29f6c4
("drm/nouveau/disp: PIOR DP uses GPIO for HPD, not PMGR AUX interrupts"),
but at least it fixes a memory corruption in error handling related to
that commit.
Link: https://lore.kernel.org/lkml/20230806213107.GFZNARG6moWpFuSJ9W@fat_crate.local/
Fixes: 95983aea8003 ("drm/nouveau/disp: add connector class")
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230814144933.3956959-1-kherbst@redhat.com
(cherry picked from commit 1b254b791d7b7dea6e8adc887fbbd51746d8bb27)
Signed-off-by: Karol Herbst <kherbst@redhat.com>
---
drivers/gpu/drm/nouveau/nouveau_connector.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 49c5451cdfb16..d6dd79541f6a9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -1407,8 +1407,7 @@ nouveau_connector_create(struct drm_device *dev,
ret = nvif_conn_ctor(&disp->disp, nv_connector->base.name, nv_connector->index,
&nv_connector->conn);
if (ret) {
- kfree(nv_connector);
- return ERR_PTR(ret);
+ goto drm_conn_err;
}
}
@@ -1470,4 +1469,9 @@ nouveau_connector_create(struct drm_device *dev,
drm_connector_register(connector);
return connector;
+
+drm_conn_err:
+ drm_connector_cleanup(connector);
+ kfree(nv_connector);
+ return ERR_PTR(ret);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 6.1.y] drm/nouveau/disp: fix use-after-free in error handling of nouveau_connector_create
2023-08-21 17:59 ` [PATCH 6.1.y] drm/nouveau/disp: fix use-after-free in error handling of nouveau_connector_create Karol Herbst
@ 2023-08-21 18:44 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2023-08-21 18:44 UTC (permalink / raw)
To: Karol Herbst; +Cc: stable, Lyude Paul
On Mon, Aug 21, 2023 at 07:59:18PM +0200, Karol Herbst wrote:
> We can't simply free the connector after calling drm_connector_init on it.
> We need to clean up the drm side first.
>
> It might not fix all regressions from commit 2b5d1c29f6c4
> ("drm/nouveau/disp: PIOR DP uses GPIO for HPD, not PMGR AUX interrupts"),
> but at least it fixes a memory corruption in error handling related to
> that commit.
>
> Link: https://lore.kernel.org/lkml/20230806213107.GFZNARG6moWpFuSJ9W@fat_crate.local/
> Fixes: 95983aea8003 ("drm/nouveau/disp: add connector class")
> Signed-off-by: Karol Herbst <kherbst@redhat.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>
> Link: https://patchwork.freedesktop.org/patch/msgid/20230814144933.3956959-1-kherbst@redhat.com
> (cherry picked from commit 1b254b791d7b7dea6e8adc887fbbd51746d8bb27)
> Signed-off-by: Karol Herbst <kherbst@redhat.com>
> ---
> drivers/gpu/drm/nouveau/nouveau_connector.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-21 19:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-21 17:03 FAILED: patch "[PATCH] drm/nouveau/disp: fix use-after-free in error handling of" failed to apply to 6.1-stable tree gregkh
2023-08-21 17:59 ` [PATCH 6.1.y] drm/nouveau/disp: fix use-after-free in error handling of nouveau_connector_create Karol Herbst
2023-08-21 18:44 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox