* FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.4-stable tree
@ 2023-07-21 12:20 gregkh
2023-07-21 12:51 ` Li, Yunxiang (Teddy)
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: gregkh @ 2023-07-21 12:20 UTC (permalink / raw)
To: Yunxiang.Li, christian.koenig; +Cc: stable
The patch below does not apply to the 6.4-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.4.y
git checkout FETCH_HEAD
git cherry-pick -x 4481913607e58196c48a4fef5e6f45350684ec3c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023072146-sports-deluge-22a1@gregkh' --subject-prefix 'PATCH 6.4.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 4481913607e58196c48a4fef5e6f45350684ec3c Mon Sep 17 00:00:00 2001
From: Yunxiang Li <Yunxiang.Li@amd.com>
Date: Thu, 22 Jun 2023 10:18:03 -0400
Subject: [PATCH] drm/ttm: fix bulk_move corruption when adding a entry
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When the resource is the first in the bulk_move range, adding it again
(thus moving it to the tail) will corrupt the list since the first
pointer is not moved. This eventually lead to null pointer deref in
ttm_lru_bulk_move_del()
Fixes: fee2ede15542 ("drm/ttm: rework bulk move handling v5")
Signed-off-by: Yunxiang Li <Yunxiang.Li@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
CC: stable@vger.kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20230622141902.28718-3-Yunxiang.Li@amd.com
Signed-off-by: Christian König <christian.koenig@amd.com>
diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
index 7333f7a87a2f..e51dbc7a2d53 100644
--- a/drivers/gpu/drm/ttm/ttm_resource.c
+++ b/drivers/gpu/drm/ttm/ttm_resource.c
@@ -86,6 +86,8 @@ static void ttm_lru_bulk_move_pos_tail(struct ttm_lru_bulk_move_pos *pos,
struct ttm_resource *res)
{
if (pos->last != res) {
+ if (pos->first == res)
+ pos->first = list_next_entry(res, lru);
list_move(&res->lru, &pos->last->lru);
pos->last = res;
}
@@ -111,7 +113,8 @@ static void ttm_lru_bulk_move_del(struct ttm_lru_bulk_move *bulk,
{
struct ttm_lru_bulk_move_pos *pos = ttm_lru_bulk_move_pos(bulk, res);
- if (unlikely(pos->first == res && pos->last == res)) {
+ if (unlikely(WARN_ON(!pos->first || !pos->last) ||
+ pos->first == res && pos->last == res)) {
pos->first = NULL;
pos->last = NULL;
} else if (pos->first == res) {
^ permalink raw reply related [flat|nested] 8+ messages in thread* RE: FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.4-stable tree
2023-07-21 12:20 FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.4-stable tree gregkh
@ 2023-07-21 12:51 ` Li, Yunxiang (Teddy)
2023-07-21 13:27 ` gregkh
2023-07-24 0:43 ` [PATCH 6.4.y] drm/ttm: fix bulk_move corruption when adding a entry Yunxiang Li
2023-07-24 0:44 ` [PATCH 6.1.y] " Yunxiang Li
2 siblings, 1 reply; 8+ messages in thread
From: Li, Yunxiang (Teddy) @ 2023-07-21 12:51 UTC (permalink / raw)
To: gregkh@linuxfoundation.org; +Cc: stable@vger.kernel.org, Koenig, Christian
[Public]
Hi Greg,
I tried this out on my side, and it seems to apply cleanly, the same goes for the 6.1.y branch.
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.4.y git checkout FETCH_HEAD git cherry-pick -x 4481913607e58196c48a4fef5e6f45350684ec3c
Regards,
Yunxiang Li
-----Original Message-----
From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
Sent: Friday, July 21, 2023 8:21
To: Li, Yunxiang (Teddy) <Yunxiang.Li@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>
Cc: stable@vger.kernel.org
Subject: FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.4-stable tree
The patch below does not apply to the 6.4-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.4.y git checkout FETCH_HEAD git cherry-pick -x 4481913607e58196c48a4fef5e6f45350684ec3c
# <resolve conflicts, build, test, etc.> git commit -s git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023072146-sports-deluge-22a1@gregkh' --subject-prefix 'PATCH 6.4.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 4481913607e58196c48a4fef5e6f45350684ec3c Mon Sep 17 00:00:00 2001
From: Yunxiang Li <Yunxiang.Li@amd.com>
Date: Thu, 22 Jun 2023 10:18:03 -0400
Subject: [PATCH] drm/ttm: fix bulk_move corruption when adding a entry
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When the resource is the first in the bulk_move range, adding it again (thus moving it to the tail) will corrupt the list since the first pointer is not moved. This eventually lead to null pointer deref in
ttm_lru_bulk_move_del()
Fixes: fee2ede15542 ("drm/ttm: rework bulk move handling v5")
Signed-off-by: Yunxiang Li <Yunxiang.Li@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
CC: stable@vger.kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20230622141902.28718-3-Yunxiang.Li@amd.com
Signed-off-by: Christian König <christian.koenig@amd.com>
diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
index 7333f7a87a2f..e51dbc7a2d53 100644
--- a/drivers/gpu/drm/ttm/ttm_resource.c
+++ b/drivers/gpu/drm/ttm/ttm_resource.c
@@ -86,6 +86,8 @@ static void ttm_lru_bulk_move_pos_tail(struct ttm_lru_bulk_move_pos *pos,
struct ttm_resource *res)
{
if (pos->last != res) {
+ if (pos->first == res)
+ pos->first = list_next_entry(res, lru);
list_move(&res->lru, &pos->last->lru);
pos->last = res;
}
@@ -111,7 +113,8 @@ static void ttm_lru_bulk_move_del(struct ttm_lru_bulk_move *bulk, {
struct ttm_lru_bulk_move_pos *pos = ttm_lru_bulk_move_pos(bulk, res);
- if (unlikely(pos->first == res && pos->last == res)) {
+ if (unlikely(WARN_ON(!pos->first || !pos->last) ||
+ pos->first == res && pos->last == res)) {
pos->first = NULL;
pos->last = NULL;
} else if (pos->first == res) {
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.4-stable tree
2023-07-21 12:51 ` Li, Yunxiang (Teddy)
@ 2023-07-21 13:27 ` gregkh
2023-07-21 20:01 ` Li, Yunxiang (Teddy)
0 siblings, 1 reply; 8+ messages in thread
From: gregkh @ 2023-07-21 13:27 UTC (permalink / raw)
To: Li, Yunxiang (Teddy); +Cc: stable@vger.kernel.org, Koenig, Christian
On Fri, Jul 21, 2023 at 12:51:26PM +0000, Li, Yunxiang (Teddy) wrote:
> [Public]
>
> Hi Greg,
>
> I tried this out on my side, and it seems to apply cleanly, the same goes for the 6.1.y branch.
> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.4.y git checkout FETCH_HEAD git cherry-pick -x 4481913607e58196c48a4fef5e6f45350684ec3c
The build breaks when you attempt to build it with it applied :(
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.4-stable tree
2023-07-21 13:27 ` gregkh
@ 2023-07-21 20:01 ` Li, Yunxiang (Teddy)
2023-07-22 11:48 ` gregkh
0 siblings, 1 reply; 8+ messages in thread
From: Li, Yunxiang (Teddy) @ 2023-07-21 20:01 UTC (permalink / raw)
To: gregkh@linuxfoundation.org; +Cc: stable@vger.kernel.org, Koenig, Christian
[Public]
Found the issue, this commit is also needed, commit 0c3855ba8dad41c4113e73f77eb926e44577e4af ("drm/ttm: fix warning that we shouldn't mix && and ||")
Sorry about that..
Teddy
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.4-stable tree
2023-07-21 20:01 ` Li, Yunxiang (Teddy)
@ 2023-07-22 11:48 ` gregkh
0 siblings, 0 replies; 8+ messages in thread
From: gregkh @ 2023-07-22 11:48 UTC (permalink / raw)
To: Li, Yunxiang (Teddy); +Cc: stable@vger.kernel.org, Koenig, Christian
On Fri, Jul 21, 2023 at 08:01:23PM +0000, Li, Yunxiang (Teddy) wrote:
> [Public]
>
> Found the issue, this commit is also needed, commit 0c3855ba8dad41c4113e73f77eb926e44577e4af ("drm/ttm: fix warning that we shouldn't mix && and ||")
I have no reference as to what you are talking about here, sorry.
Please submit the needed commits for us to apply to stable trees in full
detail, otherwise we just get confused.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 6.4.y] drm/ttm: fix bulk_move corruption when adding a entry
2023-07-21 12:20 FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.4-stable tree gregkh
2023-07-21 12:51 ` Li, Yunxiang (Teddy)
@ 2023-07-24 0:43 ` Yunxiang Li
2023-07-24 6:29 ` Greg KH
2023-07-24 0:44 ` [PATCH 6.1.y] " Yunxiang Li
2 siblings, 1 reply; 8+ messages in thread
From: Yunxiang Li @ 2023-07-24 0:43 UTC (permalink / raw)
To: stable; +Cc: Yunxiang Li, Christian König
When the resource is the first in the bulk_move range, adding it again
(thus moving it to the tail) will corrupt the list since the first
pointer is not moved. This eventually lead to null pointer deref in
ttm_lru_bulk_move_del()
Fixes: fee2ede15542 ("drm/ttm: rework bulk move handling v5")
Signed-off-by: Yunxiang Li <Yunxiang.Li@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
CC: stable@vger.kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20230622141902.28718-3-Yunxiang.Li@amd.com
Signed-off-by: Christian König <christian.koenig@amd.com>
(cherry picked from commit 4481913607e58196c48a4fef5e6f45350684ec3c)
---
drivers/gpu/drm/ttm/ttm_resource.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
index 7333f7a87a2f..46ff9c75bb12 100644
--- a/drivers/gpu/drm/ttm/ttm_resource.c
+++ b/drivers/gpu/drm/ttm/ttm_resource.c
@@ -86,6 +86,8 @@ static void ttm_lru_bulk_move_pos_tail(struct ttm_lru_bulk_move_pos *pos,
struct ttm_resource *res)
{
if (pos->last != res) {
+ if (pos->first == res)
+ pos->first = list_next_entry(res, lru);
list_move(&res->lru, &pos->last->lru);
pos->last = res;
}
@@ -111,7 +113,8 @@ static void ttm_lru_bulk_move_del(struct ttm_lru_bulk_move *bulk,
{
struct ttm_lru_bulk_move_pos *pos = ttm_lru_bulk_move_pos(bulk, res);
- if (unlikely(pos->first == res && pos->last == res)) {
+ if (unlikely(WARN_ON(!pos->first || !pos->last) ||
+ (pos->first == res && pos->last == res))) {
pos->first = NULL;
pos->last = NULL;
} else if (pos->first == res) {
--
2.41.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 6.1.y] drm/ttm: fix bulk_move corruption when adding a entry
2023-07-21 12:20 FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.4-stable tree gregkh
2023-07-21 12:51 ` Li, Yunxiang (Teddy)
2023-07-24 0:43 ` [PATCH 6.4.y] drm/ttm: fix bulk_move corruption when adding a entry Yunxiang Li
@ 2023-07-24 0:44 ` Yunxiang Li
2 siblings, 0 replies; 8+ messages in thread
From: Yunxiang Li @ 2023-07-24 0:44 UTC (permalink / raw)
To: stable; +Cc: Yunxiang Li, Christian König
When the resource is the first in the bulk_move range, adding it again
(thus moving it to the tail) will corrupt the list since the first
pointer is not moved. This eventually lead to null pointer deref in
ttm_lru_bulk_move_del()
Fixes: fee2ede15542 ("drm/ttm: rework bulk move handling v5")
Signed-off-by: Yunxiang Li <Yunxiang.Li@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
CC: stable@vger.kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20230622141902.28718-3-Yunxiang.Li@amd.com
Signed-off-by: Christian König <christian.koenig@amd.com>
(cherry picked from commit 4481913607e58196c48a4fef5e6f45350684ec3c)
---
drivers/gpu/drm/ttm/ttm_resource.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
index a729c32a1e48..3287032a2f8e 100644
--- a/drivers/gpu/drm/ttm/ttm_resource.c
+++ b/drivers/gpu/drm/ttm/ttm_resource.c
@@ -85,6 +85,8 @@ static void ttm_lru_bulk_move_pos_tail(struct ttm_lru_bulk_move_pos *pos,
struct ttm_resource *res)
{
if (pos->last != res) {
+ if (pos->first == res)
+ pos->first = list_next_entry(res, lru);
list_move(&res->lru, &pos->last->lru);
pos->last = res;
}
@@ -110,7 +112,8 @@ static void ttm_lru_bulk_move_del(struct ttm_lru_bulk_move *bulk,
{
struct ttm_lru_bulk_move_pos *pos = ttm_lru_bulk_move_pos(bulk, res);
- if (unlikely(pos->first == res && pos->last == res)) {
+ if (unlikely(WARN_ON(!pos->first || !pos->last) ||
+ (pos->first == res && pos->last == res))) {
pos->first = NULL;
pos->last = NULL;
} else if (pos->first == res) {
--
2.41.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-07-24 6:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-21 12:20 FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.4-stable tree gregkh
2023-07-21 12:51 ` Li, Yunxiang (Teddy)
2023-07-21 13:27 ` gregkh
2023-07-21 20:01 ` Li, Yunxiang (Teddy)
2023-07-22 11:48 ` gregkh
2023-07-24 0:43 ` [PATCH 6.4.y] drm/ttm: fix bulk_move corruption when adding a entry Yunxiang Li
2023-07-24 6:29 ` Greg KH
2023-07-24 0:44 ` [PATCH 6.1.y] " Yunxiang Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox