Skip to content

Commit

Permalink
RDMA: Fix use-after-free in rxe_queue_cleanup
Browse files Browse the repository at this point in the history
[ Upstream commit 84b0172 ]

On error handling path in rxe_qp_from_init() qp->sq.queue is freed and
then rxe_create_qp() will drop last reference to this object. qp clean up
function will try to free this queue one time and it causes UAF bug.

Fix it by zeroing queue pointer after freeing queue in rxe_qp_from_init().

Fixes: 514aee6 ("RDMA: Globally allocate and release QP memory")
Link: https://lore.kernel.org/r/20211121202239.3129-1-paskripkin@gmail.com
Reported-by: syzbot+aab53008a5adf26abe91@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Reviewed-by: Zhu Yanjun <zyjzyj2000@gmail.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
pskrgag authored and gregkh committed Dec 17, 2021
1 parent c0d44c5 commit acb53e4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/infiniband/sw/rxe/rxe_qp.c
Expand Up @@ -367,6 +367,7 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,

err2:
rxe_queue_cleanup(qp->sq.queue);
qp->sq.queue = NULL;
err1:
qp->pd = NULL;
qp->rcq = NULL;
Expand Down

0 comments on commit acb53e4

Please sign in to comment.