]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA: Add IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 3 Mar 2026 19:50:10 +0000 (15:50 -0400)
committerJason Gunthorpe <jgg@nvidia.com>
Sun, 8 Mar 2026 10:20:25 +0000 (06:20 -0400)
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>
drivers/infiniband/core/device.c
drivers/infiniband/core/uverbs_std_types_device.c
drivers/infiniband/hw/bnxt_re/main.c
include/rdma/ib_verbs.h
include/uapi/rdma/ib_user_ioctl_verbs.h

index 2ad760e341221db40d4163bcf336d765ae65f3ca..236061a33bf67ce39baad56cde02e14b6a7093e8 100644 (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);
index a28f9f21bed89de53f6ea313df8bfffc804f4dfb..12ca15739cd2cdf7d703ac8626fa35dae1c4cc0b 100644 (file)
@@ -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))
index b576f05e3b26b28d1960259835608f3a7ebaa884..7af514524632e2accf05e559c45327d3577526a5 100644 (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,
index effcaff455cacf2e5e2ee3c21498c18ea82e20fa..6354c613e9a81d35bd5e5dfc6913d9a7c7883a53 100644 (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
index 89e6a3f13191b91899901bdd98efa7f089bee585..90c5cd8e7753c750d2ce49fab4f4d7eeb72c0b4a 100644 (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 {