linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/12] IB: Replace safe uses for ib_get_dma_mr with pd->local_dma_lkey
@ 2015-07-30 23:22 Jason Gunthorpe
  2015-07-30 23:22 ` [PATCH v2 02/12] IB/mad: Remove ib_get_dma_mr calls Jason Gunthorpe
                   ` (11 more replies)
  0 siblings, 12 replies; 60+ messages in thread
From: Jason Gunthorpe @ 2015-07-30 23:22 UTC (permalink / raw)
  To: Doug Ledford, linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Amir Vadai, Bart Van Assche, Chien Yen, Christoph Hellwig,
	Dominique Martinet, Eli Cohen, Eric Van Hensbergen, Ido Shamay,
	Latchesar Ionkov, Or Gerlitz, Roi Dayan, Ron Minnich,
	Sagi Grimberg, Simon Derr, Tom Tucker,
	rds-devel-N0ozoZBvEnrZJqsBc5GL+g,
	target-devel-u79uwXL29TY76Z2rM5mHXA,
	v9fs-developer-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

This series moves dealing with the safe all physical mr:

  ib_get_dma_mr(pd,IB_ACCESS_LOCAL_WRITE);

Into ib_alloc_pd, and in the process makes the global local_dma_lkey functionality
broadly enabled for all ULPs.

The remaining users of ib_get_dma_mr are all unsafe:
 drivers/infiniband/ulp/iser/iser_verbs.c:
	device->mr = ib_get_dma_mr(device->pd, IB_ACCESS_LOCAL_WRITE |
				   IB_ACCESS_REMOTE_WRITE |
				   IB_ACCESS_REMOTE_READ);

 drivers/infiniband/ulp/srp/ib_srp.c:
	srp_dev->mr = ib_get_dma_mr(srp_dev->pd,
				    IB_ACCESS_LOCAL_WRITE |
				    IB_ACCESS_REMOTE_READ |
				    IB_ACCESS_REMOTE_WRITE);

 drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c:
	int acflags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE;
		mr = ib_get_dma_mr(hdev->ibh_pd, acflags);

 net/rds/iw.c:
		rds_iwdev->mr = ib_get_dma_mr(rds_iwdev->pd,
					IB_ACCESS_REMOTE_READ |
					IB_ACCESS_REMOTE_WRITE |
					IB_ACCESS_LOCAL_WRITE);

 net/sunrpc/xprtrdma/svc_rdma_transport.c:
		if (rdma_protocol_iwarp(newxprt->sc_cm_id->device,
					newxprt->sc_cm_id->port_num) &&
		    !(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG))
			dma_mr_acc |= IB_ACCESS_REMOTE_WRITE;
		newxprt->sc_phys_mr =
			ib_get_dma_mr(newxprt->sc_pd, dma_mr_acc);

 net/sunrpc/xprtrdma/verbs.c:
	case RPCRDMA_ALLPHYSICAL:
		ia->ri_ops = &rpcrdma_physical_memreg_ops;
		mem_priv = IB_ACCESS_LOCAL_WRITE |
				IB_ACCESS_REMOTE_WRITE |
				IB_ACCESS_REMOTE_READ;
		ia->ri_bind_mem = ib_get_dma_mr(ia->ri_pd, mem_priv);

Calling ib_get_dma_mr with IB_ACCESS_REMOTE_* flags is considered to be a
serious security problem and should not be done without the user directly
opting in to an off-by-default scheme. The call allows the peer on the QP
unrestricted access to local physical memory if they can guess the rkey value.

A future series will cause the kernel to be tainted by the above call sites to
promote migrating away from this.

To Migrate:
 * If ib_get_dma_mr was being used to get an lkey then use
   local_dma_lkey instead (I belive this series gets all of those cases).

   If the lkey is being used for RDMA_READ, and iWarp support is required then
   iWarp must be detected and FRMR must be used to create a limited temporary
   MR just for the RDMA_READ. (eg NFS, RDS)

 * If ib_get_dma_mr was being used to get an rkey then use FRMR to cerate
   limited temporary MR's (eg SRP, iSER, etc)

All patches are compile tested. I've done basic testing up to and including
the IPoIB patch, the rest required specialized setups I don't have access to,
but are fairly straightforward.

Jason Gunthorpe (12):
  IB/core: Guarantee that a local_dma_lkey is available
  IB/mad: Remove ib_get_dma_mr calls
  IB/ipoib: Remove ib_get_dma_mr calls
  IB/mlx4: Remove ib_get_dma_mr calls
  IB/mlx5: Remove ib_get_dma_mr calls
  IB/iser: Use pd->local_dma_lkey
  iser-target: Remove ib_get_dma_mr calls
  IB/srp: Use pd->local_dma_lkey
  IB/srp: Do not create an all physical insecure rkey by default
  ib_srpt: Remove ib_get_dma_mr calls
  net/9p: Remove ib_get_dma_mr calls
  rds/ib: Remove ib_get_dma_mr calls

 drivers/infiniband/core/mad.c                | 26 ++-------------
 drivers/infiniband/core/mad_priv.h           |  1 -
 drivers/infiniband/core/verbs.c              | 47 +++++++++++++++++++++++++---
 drivers/infiniband/hw/mlx4/mad.c             | 23 +++-----------
 drivers/infiniband/hw/mlx4/mlx4_ib.h         |  1 -
 drivers/infiniband/hw/mlx5/main.c            | 13 --------
 drivers/infiniband/hw/mlx5/mlx5_ib.h         |  1 -
 drivers/infiniband/hw/mlx5/mr.c              |  5 ++-
 drivers/infiniband/ulp/ipoib/ipoib.h         |  1 -
 drivers/infiniband/ulp/ipoib/ipoib_cm.c      |  2 +-
 drivers/infiniband/ulp/ipoib/ipoib_verbs.c   | 18 ++---------
 drivers/infiniband/ulp/iser/iscsi_iser.c     |  2 +-
 drivers/infiniband/ulp/iser/iser_initiator.c |  8 ++---
 drivers/infiniband/ulp/iser/iser_memory.c    |  2 +-
 drivers/infiniband/ulp/iser/iser_verbs.c     |  2 +-
 drivers/infiniband/ulp/isert/ib_isert.c      | 33 +++++++------------
 drivers/infiniband/ulp/isert/ib_isert.h      |  1 -
 drivers/infiniband/ulp/srp/ib_srp.c          | 33 ++++++++++++-------
 drivers/infiniband/ulp/srp/ib_srp.h          |  2 +-
 drivers/infiniband/ulp/srpt/ib_srpt.c        | 15 +++------
 drivers/infiniband/ulp/srpt/ib_srpt.h        |  1 -
 include/rdma/ib_mad.h                        |  1 -
 include/rdma/ib_verbs.h                      |  9 ++----
 net/9p/trans_rdma.c                          | 26 ++-------------
 net/rds/ib.c                                 |  8 -----
 net/rds/ib.h                                 |  2 --
 net/rds/ib_cm.c                              |  4 +--
 net/rds/ib_recv.c                            |  6 ++--
 net/rds/ib_send.c                            |  8 ++---
 29 files changed, 112 insertions(+), 189 deletions(-)

-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2015-08-16 16:56 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-30 23:22 [PATCH v2 00/12] IB: Replace safe uses for ib_get_dma_mr with pd->local_dma_lkey Jason Gunthorpe
2015-07-30 23:22 ` [PATCH v2 02/12] IB/mad: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-07-30 23:22 ` [PATCH v2 04/12] IB/mlx4: " Jason Gunthorpe
2015-07-30 23:22 ` [PATCH v2 05/12] IB/mlx5: " Jason Gunthorpe
2015-07-30 23:22 ` [PATCH v2 06/12] IB/iser: Use pd->local_dma_lkey Jason Gunthorpe
2015-07-30 23:22 ` [PATCH v2 07/12] iser-target: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-07-30 23:22 ` [PATCH v2 09/12] IB/srp: Do not create an all physical insecure rkey by default Jason Gunthorpe
2015-08-03 15:39   ` Christoph Hellwig
2015-08-03 17:18   ` Bart Van Assche
2015-07-30 23:22 ` [PATCH v2 10/12] ib_srpt: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-07-30 23:22 ` [PATCH v2 11/12] net/9p: " Jason Gunthorpe
     [not found] ` <1438298547-21404-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-07-30 23:22   ` [PATCH v2 01/12] IB/core: Guarantee that a local_dma_lkey is available Jason Gunthorpe
2015-08-02 13:09     ` Haggai Eran
2015-08-04  3:21       ` Jason Gunthorpe
2015-07-30 23:22   ` [PATCH v2 03/12] IB/ipoib: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-07-30 23:22   ` [PATCH v2 08/12] IB/srp: Use pd->local_dma_lkey Jason Gunthorpe
2015-07-31 23:05     ` Bart Van Assche
2015-07-30 23:22   ` [PATCH v2 12/12] rds/ib: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-08-14  2:47     ` santosh shilimkar
2015-07-31  7:42 ` [PATCH v2 00/12] IB: Replace safe uses for ib_get_dma_mr with pd->local_dma_lkey Christoph Hellwig
2015-07-31 13:26 ` Steve Wise
2015-07-31 22:20 ` Bart Van Assche
     [not found]   ` <55BBF4B8.2050700-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-07-31 22:31     ` Jason Gunthorpe
     [not found]       ` <20150731223153.GA1518-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-07-31 23:04         ` Bart Van Assche
     [not found]           ` <55BBFF03.7000505-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-07-31 23:14             ` Jason Gunthorpe
     [not found]               ` <20150731231430.GA1955-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-07-31 23:32                 ` Bart Van Assche
2015-08-01 20:05                 ` Doug Ledford
     [not found]                   ` <55BD2689.3080602-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-08-11 20:50                     ` Bart Van Assche
     [not found]                       ` <55CA600B.1050706-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-14 13:36                         ` Doug Ledford
     [not found]                           ` <55CDEEFA.4010803-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-08-14 16:20                             ` Bart Van Assche
     [not found]                               ` <55CE1554.60001-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-15  2:08                                 ` Doug Ledford
2015-08-03 15:24   ` Christoph Hellwig
     [not found]     ` <20150803152420.GA24193-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-08-03 18:33       ` Bart Van Assche
     [not found]         ` <55BFB40F.8000500-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-04 18:09           ` Jason Gunthorpe
     [not found]             ` <20150804180933.GB5038-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-08-05  6:41               ` David Dillow
     [not found]                 ` <1438756876.5698.2.camel-a7a0dvSY7KqLUyTwlgNVppKKF0rrzTr+@public.gmane.org>
2015-08-05 19:51                   ` Jason Gunthorpe
     [not found]                     ` <20150805195122.GA31595-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-08-05 21:45                       ` Bart Van Assche
     [not found]                         ` <55C2840C.5050301-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-05 22:41                           ` Bart Van Assche
     [not found]                             ` <55C2912A.50709-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-06  0:10                               ` Jason Gunthorpe
     [not found]                                 ` <20150806001006.GD2483-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-08-06  0:19                                   ` Bart Van Assche
     [not found]                                     ` <55C2A7FE.7020904-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-06  4:36                                       ` Jason Gunthorpe
     [not found]                                         ` <20150806043642.GA14153-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-08-06 15:09                                           ` Bart Van Assche
2015-08-11  0:05                                           ` [PATCH 0/9] IB/srp: Do not create an all physical insecure rkey by default Bart Van Assche
     [not found]                                             ` <55C93C61.9010508-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-11  0:06                                               ` [PATCH 1/8] IB/srp: Re-enable FMR for non-page aligned buffers Bart Van Assche
     [not found]                                                 ` <55C93C85.6090003-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-16 10:53                                                   ` Sagi Grimberg
     [not found]                                                     ` <55D06BB3.7070905-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-08-16 15:49                                                       ` Bart Van Assche
2015-08-11  0:06                                               ` [PATCH 2/8] IB/srp: Use multiple registrations for large memory regions Bart Van Assche
2015-08-11  0:07                                               ` [PATCH 3/8] IB/srp: Add memory descriptor array pointer range checking Bart Van Assche
     [not found]                                                 ` <55C93CBF.1060606-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-16 10:57                                                   ` Sagi Grimberg
     [not found]                                                     ` <55D06C9D.7030608-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-08-16 15:51                                                       ` Bart Van Assche
2015-08-11  0:07                                               ` [PATCH 4/8] IB/srp: Remove the memory registration backtracking code Bart Van Assche
2015-08-11  0:08                                               ` [PATCH 5/8] IB/srp: Remove use_mr argument from srp_map_sg_entry() Bart Van Assche
2015-08-11  0:08                                               ` [PATCH 6/8] IB/srp: Introduce srp_device.use_fmr Bart Van Assche
     [not found]                                                 ` <55C93D0C.7060000-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-16 11:03                                                   ` Sagi Grimberg
     [not found]                                                     ` <55D06E05.5060209-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-08-16 15:57                                                       ` Bart Van Assche
2015-08-11  0:09                                               ` [PATCH 7/8] IB/srp: Register the indirect data buffer descriptor Bart Van Assche
     [not found]                                                 ` <55C93D21.1090102-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-08-16 11:09                                                   ` Sagi Grimberg
     [not found]                                                     ` <55D06F56.4060005-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-08-16 16:56                                                       ` Bart Van Assche
2015-08-11  0:09                                               ` [PATCH 8/8] IB/srp: Create an insecure all physical rkey only if needed Bart Van Assche
2015-08-11  5:40                                               ` [PATCH 0/9] IB/srp: Do not create an all physical insecure rkey by default Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).