Skip to content

Commit 6e27f40

Browse files
zzhan461gregkh
authored andcommitted
smb: client: fix double-free in SMB2_flush() replay
commit 4be31c9 upstream. SMB2_flush() keeps its response buffer bookkeeping across replay attempts. If a replayable flush response is received and the retry then fails before cifs_send_recv() stores a replacement response, flush_exit will free the stale response pointer a second time. Reinitialize resp_buftype and rsp_iov at the top of the replay loop so cleanup only acts on response state produced by the current attempt. This fixes a double-free without changing replay handling for successful requests. Fixes: 4f1fffa ("cifs: commands that are retried should have replay flag set") Cc: stable@vger.kernel.org Reported-by: Yuan Tan <yuantan098@gmail.com> Reported-by: Zhengchuan Liang <zcliangcn@gmail.com> Reported-by: Xin Liu <bird@lzu.edu.cn> Assisted-by: Codex:GPT-5.4 Acked-by: Henrique Carvalho <henrique.carvalho@suse.com> Signed-off-by: Zhao Zhang <zzhan461@ucr.edu> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5821f9d commit 6e27f40

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/smb/client/smb2pdu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4350,6 +4350,8 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
43504350

43514351
replay_again:
43524352
/* reinitialize for possible replay */
4353+
resp_buftype = CIFS_NO_BUFFER;
4354+
memset(&rsp_iov, 0, sizeof(rsp_iov));
43534355
flags = 0;
43544356
server = cifs_pick_channel(ses);
43554357

0 commit comments

Comments
 (0)