Skip to content

Commit ef91271

Browse files
hz-chengjgunthorpe
authored andcommitted
RDMA/siw: Fix a condition race issue in MPA request processing
The calling of siw_cm_upcall and detaching new_cep with its listen_cep should be atomistic semantics. Otherwise siw_reject may be called in a temporary state, e,g, siw_cm_upcall is called but the new_cep->listen_cep has not being cleared. This fixes a WARN: WARNING: CPU: 7 PID: 201 at drivers/infiniband/sw/siw/siw_cm.c:255 siw_cep_put+0x125/0x130 [siw] CPU: 2 PID: 201 Comm: kworker/u16:22 Kdump: loaded Tainted: G E 5.17.0-rc7 rib#1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 Workqueue: iw_cm_wq cm_work_handler [iw_cm] RIP: 0010:siw_cep_put+0x125/0x130 [siw] Call Trace: <TASK> siw_reject+0xac/0x180 [siw] iw_cm_reject+0x68/0xc0 [iw_cm] cm_work_handler+0x59d/0xe20 [iw_cm] process_one_work+0x1e2/0x3b0 worker_thread+0x50/0x3a0 ? rescuer_thread+0x390/0x390 kthread+0xe5/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x1f/0x30 </TASK> Fixes: 6c52fdc ("rdma/siw: connection management") Link: https://lore.kernel.org/r/d528d83466c44687f3872eadcb8c184528b2e2d4.1650526554.git.chengyou@linux.alibaba.com Reported-by: Luis Chamberlain <[email protected]> Reviewed-by: Bernard Metzler <[email protected]> Signed-off-by: Cheng Xu <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 1c9043a commit ef91271

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/infiniband/sw/siw/siw_cm.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -968,14 +968,15 @@ static void siw_accept_newconn(struct siw_cep *cep)
968968

969969
siw_cep_set_inuse(new_cep);
970970
rv = siw_proc_mpareq(new_cep);
971-
siw_cep_set_free(new_cep);
972-
973971
if (rv != -EAGAIN) {
974972
siw_cep_put(cep);
975973
new_cep->listen_cep = NULL;
976-
if (rv)
974+
if (rv) {
975+
siw_cep_set_free(new_cep);
977976
goto error;
977+
}
978978
}
979+
siw_cep_set_free(new_cep);
979980
}
980981
return;
981982

0 commit comments

Comments
 (0)