Skip to content

Commit e85dea5

Browse files
committed
Merge tag '6.15-rc8-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: - Two fixes for use after free in readdir code paths * tag '6.15-rc8-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: smb: client: Reset all search buffer pointers when releasing buffer smb: client: Fix use-after-free in cifs_fill_dirent
2 parents 5cdb2c7 + e48f9d8 commit e85dea5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/smb/client/readdir.c

Lines changed: 5 additions & 2 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) {
@@ -756,11 +759,11 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
756759
rc = server->ops->query_dir_next(xid, tcon, &cfile->fid,
757760
search_flags,
758761
&cfile->srch_inf);
762+
if (rc)
763+
return -ENOENT;
759764
/* FindFirst/Next set last_entry to NULL on malformed reply */
760765
if (cfile->srch_inf.last_entry)
761766
cifs_save_resume_key(cfile->srch_inf.last_entry, cfile);
762-
if (rc)
763-
return -ENOENT;
764767
}
765768
if (index_to_find < cfile->srch_inf.index_of_last_entry) {
766769
/* we found the buffer that contains the entry */

0 commit comments

Comments
 (0)