summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWang Zhaolong <wangzhaolong1@huawei.com>2025-05-16 17:12:56 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-06-04 14:32:36 +0200
commit9f5748b6948174ec51d2a8a35598b224e74566d7 (patch)
tree276c5798add817794bbc0db17883135a8b759608
parentaee067e88d61eb72e966f094e4749c6b14e7008f (diff)
downloadlinux-9f5748b6948174ec51d2a8a35598b224e74566d7.tar.gz
linux-9f5748b6948174ec51d2a8a35598b224e74566d7.tar.bz2
linux-9f5748b6948174ec51d2a8a35598b224e74566d7.zip
smb: client: Reset all search buffer pointers when releasing buffer
commit e48f9d849bfdec276eebf782a84fd4dfbe1c14c0 upstream. Multiple pointers in struct cifs_search_info (ntwrk_buf_start, srch_entries_start, and last_entry) point to the same allocated buffer. However, when freeing this buffer, only ntwrk_buf_start was set to NULL, while the other pointers remained pointing to freed memory. This is defensive programming to prevent potential issues with stale pointers. While the active UAF vulnerability is fixed by the previous patch, this change ensures consistent pointer state and more robust error handling. Signed-off-by: Wang Zhaolong <wangzhaolong1@huawei.com> Cc: stable@vger.kernel.org Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Wang Zhaolong <wangzhaolong1@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/cifs/readdir.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 157aae931a18..c3156f602b20 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -621,7 +621,10 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
else
cifs_buf_release(cfile->srch_inf.
ntwrk_buf_start);
+ /* Reset all pointers to the network buffer to prevent stale references */
cfile->srch_inf.ntwrk_buf_start = NULL;
+ cfile->srch_inf.srch_entries_start = NULL;
+ cfile->srch_inf.last_entry = NULL;
}
rc = initiate_cifs_search(xid, file);
if (rc) {