Skip to content

Commit e48f9d8

Browse files
Wang Zhaolongsmfrench
authored andcommitted
smb: client: Reset all search buffer pointers when releasing buffer
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 <[email protected]> Cc: [email protected] Reviewed-by: Paulo Alcantara (Red Hat) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent a7a8fe5 commit e48f9d8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/smb/client/readdir.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,10 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
733733
else
734734
cifs_buf_release(cfile->srch_inf.
735735
ntwrk_buf_start);
736+
/* Reset all pointers to the network buffer to prevent stale references */
736737
cfile->srch_inf.ntwrk_buf_start = NULL;
738+
cfile->srch_inf.srch_entries_start = NULL;
739+
cfile->srch_inf.last_entry = NULL;
737740
}
738741
rc = initiate_cifs_search(xid, file, full_path);
739742
if (rc) {

0 commit comments

Comments
 (0)