Skip to contentSkip to conversation

FAILED: patch "[PATCH] smb: client: clear ce->tgthint in free_tgts()" failed to apply to 5.10-stable tree

PATCH New [email protected] 2 participants 2 messages Sep 3 – Sep 7

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-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-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x b1b741cf8e7ce1b91d937e23decd3d3358748700
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090318-driven-showgirl-ba4f@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From b1b741cf8e7ce1b91d937e23decd3d3358748700 Mon Sep 17 00:00:00 2001
From: Fredric Cover <[email protected]>
Date: Fri, 24 Jul 2026 15:01:46 -0700
Subject: [PATCH] smb: client: clear ce->tgthint in free_tgts()

When free_tgts() frees all structures in ce->tlist, ce->tgthint is left pointing to one of the freed cache_dfs_tgt structures.

If ce->tgthint is not reset before it is used later, it results in a use-after-free.

Set ce->tgthint to NULL in free_tgts() after the elements are freed to reflect that no elements remain.

Fixes 54be1f6c1c37 ("cifs: Add DFS cache routines")
Cc [email protected] # depends on: smb: client: harden DFS cache against invalid target hints
fs/smb/client/dfs_cache.c +2 -0
index c9ace4326a35..86dba25b7a5a 100644
@@ -122,6 +122,8 @@ static inline void free_tgts(struct cache_entry *ce)
 		kfree(t->name);
 		kfree(t);
 	}
+
+	WRITE_ONCE(ce->tgthint, NULL);
 }
 
 static inline void flush_cache_ent(struct cache_entry *ce)
maintainer
#1 lore raw

PATCH 1/1 smb: client: clear ce->tgthint in free_tgts()

From: Fredric Cover <[email protected]>

[ Upstream commit b1b741cf8e7ce1b91d937e23decd3d3358748700 ]

When free_tgts() frees all structures in ce->tlist, ce->tgthint is left pointing to one of the freed cache_dfs_tgt structures.

If ce->tgthint is not reset before it is used later, it results in a use-after-free.

Set ce->tgthint to NULL in free_tgts() after the elements are freed to reflect that no elements remain.

Fixes 54be1f6c1c37 ("cifs: Add DFS cache routines")
Cc [email protected] # depends on: smb: client: harden DFS cache against invalid target hints
---
 fs/cifs/dfs_cache.c | 2 ++
 1 file changed, 2 insertions(+)
fs/cifs/dfs_cache.c +2 -0
index 7b6db272fd0b8..115d7e276ed58 100644
@@ -118,6 +118,8 @@ static inline void free_tgts(struct cache_entry *ce)
 		kfree(t->name);
 		kfree(t);
 	}
+
+	WRITE_ONCE(ce->tgthint, NULL);
 }
 
 static inline void flush_cache_ent(struct cache_entry *ce)
Signature · 1 line
2.53.0