linux-stable/drivers/infiniband/sw/siw
Lv Yunlong 3093ee182f RDMA/siw: Fix a use after free in siw_alloc_mr
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>
2021-04-27 15:19:21 -03:00
..
iwarp.h RDMA: Delete not-used static inline functions 2021-03-22 09:31:19 -03:00
Kconfig RDMA/core: remove use of dma_virt_ops 2020-11-17 15:22:07 -04:00
Makefile
siw.h RDMA/siw: Fix handling of zero-sized Read and Receive Queues. 2021-01-08 16:29:18 -04:00
siw_cm.c RDMA/iwcm: Allow AFONLY binding for IPv6 addresses 2021-03-10 15:30:45 -04:00
siw_cm.h
siw_cq.c RDMA/siw: Simplify QP representation 2020-01-03 15:54:09 -04:00
siw_main.c RDMA/siw: Fix calculation of tx_valid_cpus size 2021-02-08 20:04:57 -04:00
siw_mem.c RDMA/siw: Fix a use after free in siw_alloc_mr 2021-04-27 15:19:21 -03:00
siw_mem.h RDMA: Delete not-used static inline functions 2021-03-22 09:31:19 -03:00
siw_qp.c RDMA/siw: Fix handling of zero-sized Read and Receive Queues. 2021-01-08 16:29:18 -04:00
siw_qp_rx.c RDMA/siw: Fix handling of zero-sized Read and Receive Queues. 2021-01-08 16:29:18 -04:00
siw_qp_tx.c RDMA/siw: Fix handling of zero-sized Read and Receive Queues. 2021-01-08 16:29:18 -04:00
siw_verbs.c RDMA: Support more than 255 rdma ports 2021-03-26 09:31:21 -03:00
siw_verbs.h RDMA: Support more than 255 rdma ports 2021-03-26 09:31:21 -03:00