]> www.infradead.org Git - users/jedix/linux-maple.git/commit
infiniband: fix a possible use-after-free bug
authorCong Wang <xiyou.wangcong@gmail.com>
Fri, 1 Jun 2018 18:31:44 +0000 (11:31 -0700)
committerBrian Maly <brian.maly@oracle.com>
Mon, 15 Oct 2018 20:23:22 +0000 (16:23 -0400)
commit077770ba0c266b52bfba798fb39c47a5edec8322
treeda6ec1f60420e4e981aaead515b008a518721f3c
parent8b44d2a3d7ada0818db085f453c4444adb21b82b
infiniband: fix a possible use-after-free bug

ucma_process_join() will free the new allocated "mc" struct,
if there is any error after that, especially the copy_to_user().

But in parallel, ucma_leave_multicast() could find this "mc"
through idr_find() before ucma_process_join() frees it, since it
is already published.

So "mc" could be used in ucma_leave_multicast() after it is been
allocated and freed in ucma_process_join(), since we don't refcnt
it.

Fix this by separating "publish" from ID allocation, so that we
can get an ID first and publish it later after copy_to_user().

Fixes: c8f6a362bf3e ("RDMA/cma: Add multicast communication support")
Reported-by: Noam Rathaus <noamr@beyondsecurity.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
(cherry picked from commit cb2595c1393b4a5211534e6f0a0fbad369e21ad8)

Orabug: 28774517
CVE: CVE-2018-14734

Reviewed-by: HÃ¥kon Bugge <haakon.bugge@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
drivers/infiniband/core/ucma.c