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>
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);
{
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))
.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,
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
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 {