1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/infiniband/hw/mlx5
Alaa Hleihel f0ae4afe3d RDMA/mlx5: Fix releasing unallocated memory in dereg MR flow
For the case of IB_MR_TYPE_DM the mr does doesn't have a umem, even though
it is a user MR. This causes function mlx5_free_priv_descs() to think that
it is a kernel MR, leading to wrongly accessing mr->descs that will get
wrong values in the union which leads to attempt to release resources that
were not allocated in the first place.

For example:
 DMA-API: mlx5_core 0000:08:00.1: device driver tries to free DMA memory it has not allocated [device address=0x0000000000000000] [size=0 bytes]
 WARNING: CPU: 8 PID: 1021 at kernel/dma/debug.c:961 check_unmap+0x54f/0x8b0
 RIP: 0010:check_unmap+0x54f/0x8b0
 Call Trace:
  debug_dma_unmap_page+0x57/0x60
  mlx5_free_priv_descs+0x57/0x70 [mlx5_ib]
  mlx5_ib_dereg_mr+0x1fb/0x3d0 [mlx5_ib]
  ib_dereg_mr_user+0x60/0x140 [ib_core]
  uverbs_destroy_uobject+0x59/0x210 [ib_uverbs]
  uobj_destroy+0x3f/0x80 [ib_uverbs]
  ib_uverbs_cmd_verbs+0x435/0xd10 [ib_uverbs]
  ? uverbs_finalize_object+0x50/0x50 [ib_uverbs]
  ? lock_acquire+0xc4/0x2e0
  ? lock_acquired+0x12/0x380
  ? lock_acquire+0xc4/0x2e0
  ? lock_acquire+0xc4/0x2e0
  ? ib_uverbs_ioctl+0x7c/0x140 [ib_uverbs]
  ? lock_release+0x28a/0x400
  ib_uverbs_ioctl+0xc0/0x140 [ib_uverbs]
  ? ib_uverbs_ioctl+0x7c/0x140 [ib_uverbs]
  __x64_sys_ioctl+0x7f/0xb0
  do_syscall_64+0x38/0x90

Fix it by reorganizing the dereg flow and mlx5_ib_mr structure:
 - Move the ib_umem field into the user MRs structure in the union as it's
   applicable only there.
 - Function mlx5_ib_dereg_mr() will now call mlx5_free_priv_descs() only
   in case there isn't udata, which indicates that this isn't a user MR.

Fixes: f18ec42231 ("RDMA/mlx5: Use a union inside mlx5_ib_mr")
Link: https://lore.kernel.org/r/66bb1dd253c1fd7ceaa9fc411061eefa457b86fb.1637581144.git.leonro@nvidia.com
Signed-off-by: Alaa Hleihel <alaa@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
2021-11-25 13:16:39 -04:00
..
ah.c RDMA: Restore ability to fail on AH destroy 2020-09-09 13:57:22 -03:00
cmd.c IB/mlx5: Enable UAR to have DevX UID 2021-09-28 18:31:21 +03:00
cmd.h IB/mlx5: Enable UAR to have DevX UID 2021-09-28 18:31:21 +03:00
cong.c RDMA: Support more than 255 rdma ports 2021-03-26 09:31:21 -03:00
counters.c RDMA/mlx5: fix build error with INFINIBAND_USER_ACCESS=n 2021-10-25 14:16:05 -03:00
counters.h RDMA: Support more than 255 rdma ports 2021-03-26 09:31:21 -03:00
cq.c Merge branch 'sg_nents' into rdma.git for-next 2021-08-30 09:49:59 -03:00
devx.c RDMA/mlx5: Attach ndescs to mlx5_ib_mkey 2021-10-19 14:42:53 +03:00
devx.h RDMA/mlx5: Attach ndescs to mlx5_ib_mkey 2021-10-19 14:42:53 +03:00
dm.c RDMA/mlx5: Verify that DM operation is reasonable 2021-05-17 13:52:47 -03:00
dm.h RDMA/mlx5: Expose UAPI to query DM 2021-04-13 19:36:37 -03:00
doorbell.c RDMA: Use the sg_table directly and remove the opencoded version from umem 2021-08-24 19:52:40 -03:00
fs.c RDMA/mlx5: Add steering support in optional flow counters 2021-10-12 12:48:06 -03:00
fs.h RDMA/mlx5: Separate flow steering logic from main.c 2020-07-07 14:05:51 -03:00
gsi.c RDMA: Globally allocate and release QP memory 2021-08-03 13:44:27 -03:00
ib_rep.c RDMA/mlx5: Add shared FDB support 2021-08-05 13:49:24 -07:00
ib_rep.h RDMA: Support more than 255 rdma ports 2021-03-26 09:31:21 -03:00
ib_virt.c RDMA: Support more than 255 rdma ports 2021-03-26 09:31:21 -03:00
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
mad.c RDMA: Support more than 255 rdma ports 2021-03-26 09:31:21 -03:00
main.c IB/mlx5: Enable UAR to have DevX UID 2021-09-28 18:31:21 +03:00
Makefile RDMA/mlx5: Move all DM logic to separate file 2021-04-13 19:36:36 -03:00
mem.c RDMA/mlx5: Silence the overflow warning while building offset mask 2020-11-26 15:49:05 -04:00
mlx5_ib.h RDMA/mlx5: Fix releasing unallocated memory in dereg MR flow 2021-11-25 13:16:39 -04:00
mr.c RDMA/mlx5: Fix releasing unallocated memory in dereg MR flow 2021-11-25 13:16:39 -04:00
odp.c RDMA v5.16 merge window pull request 2021-11-03 08:05:59 -07:00
qos.c RDMA/core: Allow the ioctl layer to abort a fully created uobject 2020-05-21 20:10:46 -03:00
qp.c RDMA/mlx5: Set user priority for DCT 2021-10-06 16:39:52 -03:00
qp.h RDMA: Restore ability to return error for destroy WQ 2020-09-09 14:14:29 -03:00
qpc.c RDMA/mlx5: Support SQD2RTS for modify QP 2021-05-20 11:41:07 -03:00
restrack.c RDMA/mlx5: Assign dev to DM MR 2020-12-07 15:52:54 -04:00
restrack.h RDMA/mlx5: Separate restrack callbacks initialization from main.c 2020-07-07 14:05:51 -03:00
srq.c RDMA/mlx5: Remove unused parameter udata 2021-05-20 11:52:17 -03:00
srq.h RDMA/mlx5: Lower setting the umem's PAS for SRQ 2020-11-16 16:53:30 -04:00
srq_cmd.c RDMA/mlx5: Lower setting the umem's PAS for SRQ 2020-11-16 16:53:30 -04:00
std_types.c RDMA/mlx5: Fill port info based on the relevant eswitch 2021-08-05 13:49:24 -07:00
wr.c RDMA/mlx5: Attach ndescs to mlx5_ib_mkey 2021-10-19 14:42:53 +03:00
wr.h RDMA/mlx5: Move all WR logic from qp.c to separate file 2020-05-06 17:42:45 -03:00