RDMA: Add IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA

This flag can be set by drivers once they have finished auditing and
implementing the full udata support on every udata operation.

My intention going forward is that driver authors proposing new udata uAPI
for their drivers must first do the work and set this flag.

If this flag is not set the userspace should not try to use udata based
uAPI newer than this commit, though on a case by case basis it may be OK
based on what checks historical kernels performed on the specific call.

Since bnxt_re is audited now, it is the first driver to set the flag.

Link: https://patch.msgid.link/r/13-v3-bd56dd443069+49-bnxt_re_uapi_jgg@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
Jason Gunthorpe
2026-03-08 06:20:25 -04:00
parent bed686d8dc
commit 613713f251
5 changed files with 17 additions and 0 deletions
+1
View File
@@ -2706,6 +2706,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
dev_ops->uverbs_no_driver_id_binding |=
ops->uverbs_no_driver_id_binding;
dev_ops->uverbs_robust_udata |= ops->uverbs_robust_udata;
SET_DEVICE_OP(dev_ops, add_gid);
SET_DEVICE_OP(dev_ops, add_sub_dev);
@@ -247,13 +247,21 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
{
u32 num_comp = attrs->ufile->device->num_comp_vectors;
u64 core_support = IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS;
struct ib_device *ib_dev;
int ret;
ib_dev = srcu_dereference(attrs->ufile->device->ib_dev,
&attrs->ufile->device->disassociate_srcu);
if (!ib_dev)
return -EIO;
ret = uverbs_copy_to(attrs, UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
&num_comp, sizeof(num_comp));
if (IS_UVERBS_COPY_ERR(ret))
return ret;
if (ib_dev->ops.uverbs_robust_udata)
core_support |= IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA;
ret = uverbs_copy_to(attrs, UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT,
&core_support, sizeof(core_support));
if (IS_UVERBS_COPY_ERR(ret))
+1
View File
@@ -1326,6 +1326,7 @@ static const struct ib_device_ops bnxt_re_dev_ops = {
.owner = THIS_MODULE,
.driver_id = RDMA_DRIVER_BNXT_RE,
.uverbs_abi_ver = BNXT_RE_ABI_VERSION,
.uverbs_robust_udata = true,
.add_gid = bnxt_re_add_gid,
.alloc_hw_port_stats = bnxt_re_ib_alloc_hw_port_stats,
+6
View File
@@ -2481,6 +2481,12 @@ struct ib_device_ops {
enum rdma_driver_id driver_id;
u32 uverbs_abi_ver;
unsigned int uverbs_no_driver_id_binding:1;
/*
* Indicates the driver checks every op accepting a udata for the
* correct size on input and always handles the output using the udata
* helpers.
*/
unsigned int uverbs_robust_udata:1;
/*
* NOTE: New drivers should not make use of device_group; instead new
+1
View File
@@ -46,6 +46,7 @@
enum ib_uverbs_core_support {
IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS = 1 << 0,
IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA = 1 << 1,
};
enum ib_uverbs_access_flags {