Skip to content

Commit 58e3ce7

Browse files
Sishuai Gongmartinetd
authored andcommitted
9p/trans_fd: avoid sending req to a cancelled conn
When a connection is cancelled by p9_conn_cancel(), all requests on it should be cancelled---mark req->status as REQ_STATUS_ERROR. However, because a race over m->err between p9_conn_cancel() and p9_fd_request(), p9_fd_request might see the old value of m->err, think that the connection is NOT cancelled, and then add new requests to this cancelled connection. Fixing this issue by lock-protecting the check on m->err. Signed-off-by: Sishuai Gong <[email protected]> Message-ID: <[email protected]> Signed-off-by: Dominique Martinet <[email protected]> Reviewed-by: Christian Schoenebeck <[email protected]>
1 parent 05d3ef8 commit 58e3ce7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/9p/trans_fd.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,14 @@ static int p9_fd_request(struct p9_client *client, struct p9_req_t *req)
671671

672672
p9_debug(P9_DEBUG_TRANS, "mux %p task %p tcall %p id %d\n",
673673
m, current, &req->tc, req->tc.id);
674-
if (m->err < 0)
675-
return m->err;
676674

677675
spin_lock(&m->req_lock);
676+
677+
if (m->err < 0) {
678+
spin_unlock(&m->req_lock);
679+
return m->err;
680+
}
681+
678682
WRITE_ONCE(req->status, REQ_STATUS_UNSENT);
679683
list_add_tail(&req->req_list, &m->unsent_req_list);
680684
spin_unlock(&m->req_lock);

0 commit comments

Comments
 (0)