Skip to content

Commit f510c7c

Browse files
Wang Zhaolongaloktiwa
authored andcommitted
smb: client: Reset all search buffer pointers when releasing buffer
commit e48f9d8 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> (cherry picked from commit 9f5748b6948174ec51d2a8a35598b224e74566d7) Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
1 parent 9484024 commit f510c7c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/cifs/readdir.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,10 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
621621
else
622622
cifs_buf_release(cfile->srch_inf.
623623
ntwrk_buf_start);
624+
/* Reset all pointers to the network buffer to prevent stale references */
624625
cfile->srch_inf.ntwrk_buf_start = NULL;
626+
cfile->srch_inf.srch_entries_start = NULL;
627+
cfile->srch_inf.last_entry = NULL;
625628
}
626629
rc = initiate_cifs_search(xid, file);
627630
if (rc) {

0 commit comments

Comments
 (0)