Message ID | 20211121202239.3129-1-paskripkin@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Jason Gunthorpe |
Headers | show |
Series | RDMA: fix use-after-free in rxe_queue_cleanup | expand |
On Mon, Nov 22, 2021 at 4:22 AM Pavel Skripkin <paskripkin@gmail.com> wrote: > > 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: 514aee660df4 ("RDMA: Globally allocate and release QP memory") > Reported-by: syzbot+aab53008a5adf26abe91@syzkaller.appspotmail.com > Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> Reviewed-by: Zhu Yanjun <zyjzyj2000@gmail.com> Thanks a lot. Zhu Yanjun > --- > drivers/infiniband/sw/rxe/rxe_qp.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c > index 975321812c87..54b8711321c1 100644 > --- a/drivers/infiniband/sw/rxe/rxe_qp.c > +++ b/drivers/infiniband/sw/rxe/rxe_qp.c > @@ -359,6 +359,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; > -- > 2.33.1 >
On Sun, Nov 21, 2021 at 11:22:39PM +0300, Pavel Skripkin wrote: > 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: 514aee660df4 ("RDMA: Globally allocate and release QP memory") > Reported-by: syzbot+aab53008a5adf26abe91@syzkaller.appspotmail.com > Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> > Reviewed-by: Zhu Yanjun <zyjzyj2000@gmail.com> > --- > drivers/infiniband/sw/rxe/rxe_qp.c | 1 + > 1 file changed, 1 insertion(+) Applied to for-next, thanks Jason
diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index 975321812c87..54b8711321c1 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -359,6 +359,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;
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: 514aee660df4 ("RDMA: Globally allocate and release QP memory") Reported-by: syzbot+aab53008a5adf26abe91@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> --- drivers/infiniband/sw/rxe/rxe_qp.c | 1 + 1 file changed, 1 insertion(+)