RDMA/efa: Validate SQ ring size against max LLQ size
Subsystems (2)
PATCH 1/1 RDMA/efa: Validate SQ ring size against max LLQ size
Validate the SQ ring size against the device's max LLQ size. This ensures that when using 128-byte WQEs, userspace cannot exceed the queue limits.
On create QP, userspace provides the SQ ring size (depth x WQE size) which is validated against the max LLQ size.
--- drivers/infiniband/hw/efa/efa_verbs.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/infiniband/hw/efa/efa_verbs.c +18 -9
@@ -598,7 +598,8 @@ static int qp_mmap_entries_setup(struct efa_qp *qp, }static int efa_qp_validate_cap (struct efa_dev *dev, -struct ib_qp_init_attr *init_attr) +struct ib_qp_init_attr *init_attr, +u32 sq_ring_size) {if (init_attr->cap.max_send_wr > dev->dev_attr.max_sq_depth) { ibdev_dbg(&dev->ibdev,
@@ -607,6 +608,14 @@ static int efa_qp_validate_cap(struct efa_dev *dev, dev->dev_attr.max_sq_depth);return -EINVAL ; } + +if (sq_ring_size > dev->dev_attr.max_llq_size) { +ibdev_dbg (&dev->ibdev, +"qp: requested sq ring size[%u] exceeds the max[%u]\n" , + sq_ring_size, dev->dev_attr.max_llq_size); +return -EINVAL ; + } +if (init_attr->cap.max_recv_wr > dev->dev_attr.max_rq_depth) { ibdev_dbg(&dev->ibdev, "qp: requested receive wr[%u] exceeds the max[%u]\n",
@@ -676,14 +685,6 @@ int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr, ucontext = rdma_udata_to_drv_context(udata, struct efa_ucontext, ibucontext); - err =efa_qp_validate_cap (dev, init_attr); -if (err) - goto err_out; - - err =efa_qp_validate_attr (dev, init_attr); -if (err) - goto err_out; - err =ib_copy_validate_udata_in_cm (udata, cmd, driver_qp_type,0 );if (err) goto err_out;
@@ -705,6 +706,14 @@ int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr, goto err_out; } + err =efa_qp_validate_cap (dev, init_attr, cmd.sq_ring_size); +if (err) + goto err_out; + + err =efa_qp_validate_attr (dev, init_attr); +if (err) + goto err_out; + create_qp_params.uarn = ucontext->uarn; create_qp_params.pd =to_epd (ibqp->pd)->pdn;
Signature · 1 line
2.50.1
Quoted 76 lines · Yonatan Nachum
Validate the SQ ring size against the device's max LLQ size. This ensures that when using 128-byte WQEs, userspace cannot exceed the queue limits.
On create QP, userspace provides the SQ ring size (depth x WQE size) which is validated against the max LLQ size.
Fixes 40909f664d27 ("RDMA/efa: Add EFA verbs implementation")Reviewed-by Michael Margolin <[email protected]>Signed-off-by Yonatan Nachum <[email protected]>--- drivers/infiniband/hw/efa/efa_verbs.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/infiniband/hw/efa/efa_verbs.c +18
-9@@ -598,7 +598,8 @@ static int qp_mmap_entries_setup(struct efa_qp *qp, }static int efa_qp_validate_cap (struct efa_dev *dev, -struct ib_qp_init_attr *init_attr) +struct ib_qp_init_attr *init_attr, +u32 sq_ring_size) {if (init_attr->cap.max_send_wr > dev->dev_attr.max_sq_depth) { ibdev_dbg(&dev->ibdev,@@ -607,6 +608,14 @@ static int efa_qp_validate_cap(struct efa_dev *dev, dev->dev_attr.max_sq_depth);return -EINVAL ; } + +if (sq_ring_size > dev->dev_attr.max_llq_size) { +ibdev_dbg (&dev->ibdev, +"qp: requested sq ring size[%u] exceeds the max[%u]\n" , + sq_ring_size, dev->dev_attr.max_llq_size); +return -EINVAL ; + } +if (init_attr->cap.max_recv_wr > dev->dev_attr.max_rq_depth) { ibdev_dbg(&dev->ibdev, "qp: requested receive wr[%u] exceeds the max[%u]\n",@@ -676,14 +685,6 @@ int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr, ucontext = rdma_udata_to_drv_context(udata, struct efa_ucontext, ibucontext); - err =efa_qp_validate_cap (dev, init_attr); -if (err) - goto err_out; - - err =efa_qp_validate_attr (dev, init_attr); -if (err) - goto err_out; - err =ib_copy_validate_udata_in_cm (udata, cmd, driver_qp_type,0 );if (err) goto err_out;@@ -705,6 +706,14 @@ int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr, goto err_out; } + err =efa_qp_validate_cap (dev, init_attr, cmd.sq_ring_size); +if (err) + goto err_out; + + err =efa_qp_validate_attr (dev, init_attr); +if (err) + goto err_out; + create_qp_params.uarn = ucontext->uarn; create_qp_params.pd =to_epd (ibqp->pd)->pdn;Signature · 1 line
2.50.1
Hi, kind reminder
Thanks
Jason Gunthorpe
maintainerQuoted 7 lines · Yonatan Nachum
Validate the SQ ring size against the device's max LLQ size. This ensures that when using 128-byte WQEs, userspace cannot exceed the queue limits.
On create QP, userspace provides the SQ ring size (depth x WQE size) which is validated against the max LLQ size.
Quoted 6 lines
Fixes 40909f664d27 ("RDMA/efa: Add EFA verbs implementation")Reviewed-by Michael Margolin <[email protected]>Signed-off-by Yonatan Nachum <[email protected]>--- drivers/infiniband/hw/efa/efa_verbs.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
The Sashiko comments look like they are worth addressing
https://sashiko.dev/#/patchset/20260517175216.614494-1-ynachum%40amazon.com
Jason
Re: [PATCH for-rc] RDMA/efa: Validate SQ ring size against max LLQ sizey
Quoted 15 lines · Jason Gunthorpe
Quoted 7 lines · Yonatan Nachum
Validate the SQ ring size against the device's max LLQ size. This ensures that when using 128-byte WQEs, userspace cannot exceed the queue limits.
On create QP, userspace provides the SQ ring size (depth x WQE size) which is validated against the max LLQ size.
Quoted 6 lines
Fixes 40909f664d27 ("RDMA/efa: Add EFA verbs implementation")Reviewed-by Michael Margolin <[email protected]>Signed-off-by Yonatan Nachum <[email protected]>--- drivers/infiniband/hw/efa/efa_verbs.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
Quoted 5 lines
The Sashiko comments look like they are worth addressing
https://sashiko.dev/#/patchset/20260517175216.614494-1-ynachum%40amazon.com
Jason
Hi, thanks for the answer.
That is not the Sashiko link for the patch, its this:
https://sashiko.dev/#/patchset/20260526081536.1203553-1-ynachum%40amazon.com
I reviewed the comments and none of them is relevant for the patch.
Thanks
Jason Gunthorpe
maintainerRe: [PATCH for-rc] RDMA/efa: Validate SQ ring size against max LLQ sizey
Quoted 18 lines · Yonatan Nachum
Quoted 17 lines · Jason Gunthorpe
Quoted 7 lines · Yonatan Nachum
Validate the SQ ring size against the device's max LLQ size. This ensures that when using 128-byte WQEs, userspace cannot exceed the queue limits.
On create QP, userspace provides the SQ ring size (depth x WQE size) which is validated against the max LLQ size.
Quoted 6 lines
Fixes 40909f664d27 ("RDMA/efa: Add EFA verbs implementation")Reviewed-by Michael Margolin <[email protected]>Signed-off-by Yonatan Nachum <[email protected]>--- drivers/infiniband/hw/efa/efa_verbs.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)The Sashiko comments look like they are worth addressing
Quoted 7 lines
Quoted 3 lines
https://sashiko.dev/#/patchset/20260517175216.614494-1-ynachum%40amazon.com
Jason
Hi, thanks for the answer.
That is not the Sashiko link for the patch, its this:
https://sashiko.dev/#/patchset/20260526081536.1203553-1-ynachum%40amazon.com
Oh boy, it is annoying to get the right one up :\
Quoted 1 line
I reviewed the comments and none of them is relevant for the patch.
Ok, applied to for-rc
Thanks,
Jason