]> git.baikalelectronics.ru Git - kernel.git/commit
net/rds: Fix MR reference counting problem
authorKa-Cheong Poon <ka-cheong.poon@oracle.com>
Wed, 8 Apr 2020 10:21:02 +0000 (03:21 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 9 Apr 2020 17:22:00 +0000 (10:22 -0700)
commit47e1188110029148ff9bd0f2d25657b4326bac09
tree5c318bbf58af67e56b085332648cac599973b3fb
parentfbcfe14e5f7e8136a7820670ad79a36a69d1b86d
net/rds: Fix MR reference counting problem

In rds_free_mr(), it calls rds_destroy_mr(mr) directly.  But this
defeats the purpose of reference counting and makes MR free handling
impossible.  It means that holding a reference does not guarantee that
it is safe to access some fields.  For example, In
rds_cmsg_rdma_dest(), it increases the ref count, unlocks and then
calls mr->r_trans->sync_mr().  But if rds_free_mr() (and
rds_destroy_mr()) is called in between (there is no lock preventing
this to happen), r_trans_private is set to NULL, causing a panic.
Similar issue is in rds_rdma_unuse().

Reported-by: zerons <sironhide0null@gmail.com>
Signed-off-by: Ka-Cheong Poon <ka-cheong.poon@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/rdma.c
net/rds/rds.h