cifs: fix race between compound_send_recv() and the demultiplex thread
Subsystems (2)
cover cifs: fix race between compound_send_recv() and the demultiplex thread
List, Pavel
Here is a small patch that fixes another race where we leak a handle on an interrupted open() Please review.
PATCH 1/1 cifs: fix race between compound_send_recv() and the demultiplex thread
There is a race where the open() may be interrupted between when we receive the reply but before we have invoked the callback in which case we never end up calling handle_cancelled_mid() and thus leak an open handle on the server.
Signed-off-by Ronnie Sahlberg <[email protected]>
--- fs/cifs/connect.c | 1 - fs/cifs/transport.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/cifs/connect.c +0 -1
@@ -1223,7 +1223,6 @@ cifs_demultiplex_thread(void *p)if (mids[i] !=NULL ) { mids[i]->resp_buf_size = server->pdu_size;if ((mids[i]->mid_flags &MID_WAIT_CANCELLED ) && - mids[i]->mid_state ==MID_RESPONSE_RECEIVED && server->ops->handle_cancelled_mid) server->ops->handle_cancelled_mid( mids[i]->resp_buf,
fs/cifs/transport.c +2 -1
@@ -1119,7 +1119,8 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, midQ[i]->mid, le16_to_cpu(midQ[i]->command));send_cancel (server, &rqst[i], midQ[i]);spin_lock (&GlobalMid_Lock); -if (midQ[i]->mid_state ==MID_REQUEST_SUBMITTED ) { +if (midQ[i]->mid_state ==MID_REQUEST_SUBMITTED || + midQ[i]->mid_state ==MID_RESPONSE_RECEIVED ) { midQ[i]->mid_flags |=MID_WAIT_CANCELLED ; midQ[i]->callback = cifs_cancelled_callback; cancelled_mid[i] = true;
Signature · 1 line
2.13.6