aboutsummaryrefslogtreecommitdiff
path: root/include/linux/overflow.h
diff options
context:
space:
mode:
authorCong Wang <[email protected]>2018-09-12 16:27:44 -0700
committerDoug Ledford <[email protected]>2018-09-13 13:04:13 -0400
commit5fe23f262e0548ca7f19fb79f89059a60d087d22 (patch)
tree33c44b6bd334656e0222fbf3fb4ee99306392cbf /include/linux/overflow.h
parent67e3816842fe6414d629c7515b955952ec40c7d7 (diff)
ucma: fix a use-after-free in ucma_resolve_ip()
There is a race condition between ucma_close() and ucma_resolve_ip(): CPU0 CPU1 ucma_resolve_ip(): ucma_close(): ctx = ucma_get_ctx(file, cmd.id); list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) { mutex_lock(&mut); idr_remove(&ctx_idr, ctx->id); mutex_unlock(&mut); ... mutex_lock(&mut); if (!ctx->closing) { mutex_unlock(&mut); rdma_destroy_id(ctx->cm_id); ... ucma_free_ctx(ctx); ret = rdma_resolve_addr(); ucma_put_ctx(ctx); Before idr_remove(), ucma_get_ctx() could still find the ctx and after rdma_destroy_id(), rdma_resolve_addr() may still access id_priv pointer. Also, ucma_put_ctx() may use ctx after ucma_free_ctx() too. ucma_close() should call ucma_put_ctx() too which tests the refcnt and waits for the last one releasing it. The similar pattern is already used by ucma_destroy_id(). Reported-and-tested-by: [email protected] Reported-by: [email protected] Cc: Jason Gunthorpe <[email protected]> Cc: Doug Ledford <[email protected]> Cc: Leon Romanovsky <[email protected]> Signed-off-by: Cong Wang <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
Diffstat (limited to 'include/linux/overflow.h')
0 files changed, 0 insertions, 0 deletions