FAILED: patch "[PATCH] drm/ttm: fix bulk_move corruption when adding a entry" failed to apply to 6.1-stable tree
Subsystems (4)
[email protected]
maintainerThe 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 <[email protected]>.
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 4481913607e58196c48a4fef5e6f45350684ec3c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023072147-outfit-hermit-0f79@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
4481913607e5 ("drm/ttm: fix bulk_move corruption when adding a entry")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 4481913607e58196c48a4fef5e6f45350684ec3c Mon Sep 17 00:00:00 2001
From: Yunxiang Li <[email protected]>
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()
drivers/gpu/drm/ttm/ttm_resource.c +4 -1
@@ -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) {