smb: client: fix double-free in SMB2_flush() replay
Subsystems (2)
PATCH 1/1 smb: client: fix double-free in SMB2_flush() replay
In reply to a message not in the archiveFrom: Zhao Zhang <[email protected]>
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.
--- fs/smb/client/smb2pdu.c | 2 ++ 1 file changed, 2 insertions(+)
fs/smb/client/smb2pdu.c +2 -0
@@ -4433,6 +4433,8 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, replay_again:/* reinitialize for possible replay */ + resp_buftype =CIFS_NO_BUFFER ; +memset (&rsp_iov,0 ,sizeof (rsp_iov)); flags =0 ; server =cifs_pick_channel (ses);
Signature · 1 line
2.47.3
tentatively merged into cifs-2.6.git for-next pending testing and additional review
Quoted 42 lines · Ren Wei
From: Zhao Zhang <[email protected]>
SMB2_flush()keeps its response buffer bookkeeping across replay attempts. If a replayable flush response is received and the retry then fails beforecifs_send_recv()stores a replacement response,flush_exitwill free the stale response pointer a second time.Reinitialize
resp_buftypeandrsp_iovat 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 4f1fffa23769 ("cifs: commands that are retried should have replay flag set")Reported-by Yuan Tan <[email protected]>Reported-by Zhengchuan Liang <[email protected]>Reported-by Xin Liu <[email protected]>Assisted-by Codex:GPT-5.4Signed-off-by Zhao Zhang <[email protected]>Signed-off-by Ren Wei <[email protected]>--- fs/smb/client/smb2pdu.c | 2 ++ 1 file changed, 2 insertions(+)fs/smb/client/smb2pdu.c +2
-1@@ -4433,6 +4433,8 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, replay_again:/* reinitialize for possible replay */ + resp_buftype =CIFS_NO_BUFFER ; +memset (&rsp_iov,0 ,sizeof (rsp_iov)); flags =0 ; server =cifs_pick_channel (ses); --2.47.3
Signature · 3 lines
Thanks, Steve