RDMA/mana_ib: return PD number to the user
PATCH v2 1/1 RDMA/mana_ib: return PD number to the user
From: Konstantin Taranov <[email protected]>
Implement returning to userspace applications PDNs of created PDs. The PDN is used by applications that build work requests outside of the rdma-core code base. The PDN is used to build work requests that require additional PD isolation checks. The requests can fit only 16 bit PDNs. Allow users to request short PDNs which are 16 bits.
---
v2: updated commit message
drivers/infiniband/hw/mana/main.c | 19 ++++++++++++++++++- include/net/mana/gdma.h | 4 ++-- include/uapi/rdma/mana-abi.h | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mana/main.c +18 -1
@@ -69,9 +69,11 @@ int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd,int mana_ib_alloc_pd (struct ib_pd *ibpd,struct ib_udata *udata) { struct mana_ib_pd *pd = container_of(ibpd, struct mana_ib_pd, ibpd); +struct mana_ib_alloc_pd_resp cmd_resp = {};struct ib_device *ibdev = ibpd->device;struct gdma_create_pd_resp resp = {};struct gdma_create_pd_req req = {}; +struct mana_ib_alloc_pd ucmd = {};enum gdma_pd_flags flags =0 ;struct mana_ib_dev *dev;struct gdma_context *gc;
@@ -83,8 +85,15 @@ int mana_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)mana_gd_init_req_hdr (&req.hdr,GDMA_CREATE_PD ,sizeof (req),sizeof (resp)); -if (!udata) +if (!udata) { flags |=GDMA_PD_FLAG_ALLOW_GPA_MR ; + }else { + err =ib_copy_from_udata (&ucmd, udata,min (sizeof (ucmd), udata->inlen)); +if (err) +return err; +if (ucmd.flags &MANA_IB_PD_SHORT_PDN ) + flags |=GDMA_PD_FLAG_SHORT_PDN ; + } req.flags = flags; err = mana_gd_send_request(gc, sizeof(req), &req,
@@ -107,6 +116,14 @@ int mana_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)mutex_init (&pd->vport_mutex); pd->vport_use_count =0 ; + +if (udata) { + cmd_resp.pdn = resp.pd_id; + err =ib_copy_to_udata (udata, &cmd_resp,min (sizeof (cmd_resp), udata->outlen)); +if (err) +return err; + } +return 0 ; }
include/net/mana/gdma.h +2 -2
@@ -824,8 +824,8 @@ struct gdma_destroy_dma_region_req { };/* HW DATA */ enum gdma_pd_flags { -GDMA_PD_FLAG_INVALID =0 , -GDMA_PD_FLAG_ALLOW_GPA_MR =1 , +GDMA_PD_FLAG_ALLOW_GPA_MR =BIT (0 ), +GDMA_PD_FLAG_SHORT_PDN =BIT (2 ), };struct gdma_create_pd_req {
include/uapi/rdma/mana-abi.h +14 -0
@@ -87,4 +87,18 @@ struct mana_ib_create_qp_rss_resp { struct rss_resp_entry entries[64]; }; +enum mana_ib_create_pd_flags { +MANA_IB_PD_SHORT_PDN =1 <<0 , +}; + +struct mana_ib_alloc_pd { +__u32 flags; +__u32 reserved; +}; + +struct mana_ib_alloc_pd_resp { +__u32 pdn; +__u32 reserved; +}; +#endif
Signature · 1 line
2.43.0
Quoted 7 lines · Konstantin Taranov
From: Konstantin Taranov <[email protected]>
Implement returning to userspace applications PDNs of created PDs. The PDN is used by applications that build work requests outside of the rdma-core code base. The PDN is used to build work requests that require additional PD isolation checks. The requests can fit only 16 bit PDNs. Allow users to request short PDNs which are 16 bits.
What?
PDN is protected information it should never be given to the HW directly from userspace.
How can this possibly be secure?
Jason
Konstantin Taranov
maintainerQuoted 9 lines · Konstantin Taranov
Quoted 6 lines
From: Konstantin Taranov <[email protected]>
Implement returning to userspace applications PDNs of created PDs. The PDN is used by applications that build work requests outside of the rdma-core code base. The PDN is used to build work requests that require additional PD isolation checks. The requests can fit only 16 bit
PDNs.
Quoted 8 lines
Quoted 1 line
Allow users to request short PDNs which are 16 bits.
What?
PDN is protected information it should never be given to the HW directly from userspace.
How can this possibly be secure?
As far as I know, it is secure as classical PD check for WQ exists and it is just some additional requirement to mention PDN in a request. I am not the one
who created this requirement to mention PDN in the request, but I got an ask to expose that since some vendors do that, and there were no security concerns (see struct mlx5dv_pd from mlx5dv_init_obj()). It seems is not a concern when the PDN is set from user-space into the address vector (see fill_ud_av() from hns, mlx4_create_ah(). and mthca_alloc_av()). As far as I understand, the use-case aimed here is similar to address vectors.
- Konstantin
Quoted 2 lines
Jason
Quoted 13 lines · Konstantin Taranov
Quoted 13 lines · Konstantin Taranov
Quoted 6 lines
From: Konstantin Taranov <[email protected]>
Implement returning to userspace applications PDNs of created PDs. The PDN is used by applications that build work requests outside of the rdma-core code base. The PDN is used to build work requests that require additional PD isolation checks. The requests can fit only 16 bit
PDNs.
Quoted 1 line
Allow users to request short PDNs which are 16 bits.
What?
Quoted 7 lines
Quoted 4 lines
PDN is protected information it should never be given to the HW directly from userspace.
How can this possibly be secure?
As far as I know, it is secure as classical PD check for WQ exists and it is just some additional requirement to mention PDN in a request.
If all you are doing is sending a PDN in a WQ that must always match that PDN that the WQ already has then I would agree that is OK.
But a completely nonsensical thing to do - to the point I'm skeptical that it is actually being validated ???
Quoted 4 lines
I am not the one who created this requirement to mention PDN in the request, but I got an ask to expose that since some vendors do that, and there were no security concerns (see struct
mlx5dv_pdfrommlx5dv_init_obj()).
That's different, that is going through a FW path and mlx5 has a UID mechanism to link the permitted PDN to the user making the request.
Quoted 4 lines
It seems is not a concern when
the PDN is set from user-space into the address vector (seefill_ud_av()from hns,mlx4_create_ah(). andmthca_alloc_av()). As far as I understand, the use-case aimed here is similar to address vectors.
All these AH cases all end up with checks in SW or HW that the PDN is valid for the context. What you are describing could be real, but is so hard to accept that I'm going to ask you to strongly verify it and document all this in the commit message.
Jason