public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] IB: Replace safe uses for ib_get_dma_mr with pd->local_dma_lkey
@ 2015-07-22 23:34 Jason Gunthorpe
  2015-07-22 23:34 ` [PATCH 01/10] IB/core: Guarantee that a local_dma_lkey is available Jason Gunthorpe
                   ` (9 more replies)
  0 siblings, 10 replies; 31+ messages in thread
From: Jason Gunthorpe @ 2015-07-22 23:34 UTC (permalink / raw)
  To: Doug Ledford, linux-rdma
  Cc: Amir Vadai, Andy Grover, 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,
	Zach Brown, rds-devel, target-devel, v9fs-developer

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)

Doug, this needs to be sequenced after the mlx5 patch:
 https://patchwork.kernel.org/patch/6829351/

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. Feel free to take whatever subset of this gets
tested/ack'd before the next cycle.

Sagi, IB/iser should have special attention paid, as it is less clear to me if
it got everything.

Jason Gunthorpe (10):
  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_srpt: Remove ib_get_dma_mr calls
  net/9p: Remove ib_get_dma_mr calls

 drivers/infiniband/core/mad.c                | 26 +++---------------
 drivers/infiniband/core/mad_priv.h           |  1 -
 drivers/infiniband/core/verbs.c              | 40 ++++++++++++++++++++++++----
 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          |  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                      |  2 ++
 net/9p/trans_rdma.c                          | 26 ++----------------
 23 files changed, 75 insertions(+), 151 deletions(-)

-- 
2.1.4

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

end of thread, other threads:[~2015-07-29 16:39 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-22 23:34 [PATCH 00/10] IB: Replace safe uses for ib_get_dma_mr with pd->local_dma_lkey Jason Gunthorpe
2015-07-22 23:34 ` [PATCH 01/10] IB/core: Guarantee that a local_dma_lkey is available Jason Gunthorpe
2015-07-23 10:47   ` Sagi Grimberg
2015-07-23 18:36     ` Jason Gunthorpe
     [not found] ` <1437608083-22898-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-07-22 23:34   ` [PATCH 02/10] IB/mad: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-07-22 23:34   ` [PATCH 03/10] IB/ipoib: " Jason Gunthorpe
2015-07-22 23:34   ` [PATCH 07/10] iser-target: " Jason Gunthorpe
2015-07-23 10:49     ` Sagi Grimberg
2015-07-22 23:34   ` [PATCH 08/10] IB/srp: Use pd->local_dma_lkey Jason Gunthorpe
     [not found]     ` <1437608083-22898-9-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-07-23 10:50       ` Sagi Grimberg
2015-07-22 23:34 ` [PATCH 04/10] IB/mlx4: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-07-22 23:34 ` [PATCH 05/10] IB/mlx5: " Jason Gunthorpe
2015-07-22 23:34 ` [PATCH 06/10] IB/iser: Use pd->local_dma_lkey Jason Gunthorpe
2015-07-23 10:49   ` Sagi Grimberg
2015-07-22 23:34 ` [PATCH 09/10] ib_srpt: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-07-23 10:51   ` Sagi Grimberg
2015-07-22 23:34 ` [PATCH 10/10] net/9p: " Jason Gunthorpe
2015-07-23  7:46   ` Dominique Martinet
2015-07-23 10:56 ` [PATCH 00/10] IB: Replace safe uses for ib_get_dma_mr with pd->local_dma_lkey Sagi Grimberg
2015-07-23 13:47 ` Bart Van Assche
2015-07-23 18:30   ` Jason Gunthorpe
     [not found]     ` <20150723183044.GA1868-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-07-23 18:42       ` Bart Van Assche
     [not found]         ` <55B13583.5010208-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-07-23 18:47           ` Jason Gunthorpe
2015-07-26  8:45             ` Sagi Grimberg
2015-07-29 16:39             ` Doug Ledford
2015-07-25  6:27   ` Christoph Hellwig
2015-07-28 15:01 ` J.L. Burr
2015-07-28 18:23   ` Jason Gunthorpe
2015-07-28 20:58     ` J.L. Burr
2015-07-28 22:10       ` Jason Gunthorpe
2015-07-28 23:56         ` J.L. Burr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox