linux_dsm_epyc7002/drivers/infiniband
Lv Yunlong 608a4b90ec RDMA/siw: Fix a use after free in siw_alloc_mr
[ Upstream commit 3093ee182f01689b89e9f8797b321603e5de4f63 ]

Our code analyzer reported a UAF.

In siw_alloc_mr(), it calls siw_mr_add_mem(mr,..). In the implementation of
siw_mr_add_mem(), mem is assigned to mr->mem and then mem is freed via
kfree(mem) if xa_alloc_cyclic() failed. Here, mr->mem still point to a
freed object. After, the execution continue up to the err_out branch of
siw_alloc_mr, and the freed mr->mem is used in siw_mr_drop_mem(mr).

My patch moves "mr->mem = mem" behind the if (xa_alloc_cyclic(..)<0) {}
section, to avoid the uaf.

Fixes: 2251334dca ("rdma/siw: application buffer management")
Link: https://lore.kernel.org/r/20210426011647.3561-1-lyl2019@mail.ustc.edu.cn
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Reviewed-by: Bernard Metzler <bmt@zurich.ihm.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-05-14 09:50:44 +02:00
..
core RDMA/core: Add CM to restrack after successful attachment to a device 2021-05-14 09:50:42 +02:00
hw RDMA/i40iw: Fix error unwinding when i40iw_hmc_sd_one fails 2021-05-14 09:50:40 +02:00
sw RDMA/siw: Fix a use after free in siw_alloc_mr 2021-05-14 09:50:44 +02:00
ulp RDMA/rtrs-clt: destroy sysfs after removing session from active list 2021-05-14 09:50:36 +02:00
Kconfig RMDA/sw: Don't allow drivers using dma_virt_ops on highmem configs 2020-11-12 13:27:41 -04:00
Makefile