| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/07/10 03:55 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": [
"INFINIBAND",
"CGROUP_RDMA",
"SMC",
"INFINIBAND_SRP",
"RDMA_RXE"
],
"FocusSymbols": [
"ib_device_set_netns_put",
"rdma_dev_change_netns",
"rdma_dev_pick_netns_name",
"nldev_set_doit",
"rdmacg_device_visible",
"smc_pnet_find_ib",
"srp_net_namespace",
"__alloc_name_id",
"rdma_dev_name_in_netns"
],
"Reasoning": "The patch introduces net namespace support for RDMA devices, allowing them to be isolated and renamed per network namespace. This involves functional changes to the RDMA core, RDMA cgroups, SMC, and SRP. These changes are reachable from userspace via netlink and cgroupfs, and thus should be fuzzed.",
"WorthFuzzing": true
} |
| 1/1 | 2026/07/10 03:55 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 076ae9f7c55935fb1c38b8986d905d4eed559f6b\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Fri Jul 10 03:55:24 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/Documentation/ABI/testing/configfs-rdma_cm b/Documentation/ABI/testing/configfs-rdma_cm\nindex 74f9506f42e7ac..739f7b6a12598b 100644\n--- a/Documentation/ABI/testing/configfs-rdma_cm\n+++ b/Documentation/ABI/testing/configfs-rdma_cm\n@@ -12,6 +12,10 @@ Description: \tInterface is used to configure RDMA-cable HCAs in respect to\n \t\tfor this HCA has to be created:\n \t\tmkdir -p /config/rdma_cm/\u003chca\u003e\n \n+\t\tNote: configfs has no network namespace support, so this\n+\t\tinterface cannot represent two devices that share a name in\n+\t\tdifferent network namespaces (possible in exclusive netns mode).\n+\n \n What: \t\t/config/rdma_cm/\u003chca\u003e/ports/\u003cport-num\u003e/default_roce_mode\n Date: \t\tNovember 29, 2015\ndiff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst\nindex 993446ab66d0fb..4523c1884d6715 100644\n--- a/Documentation/admin-guide/cgroup-v2.rst\n+++ b/Documentation/admin-guide/cgroup-v2.rst\n@@ -2752,6 +2752,13 @@ RDMA\n The \"rdma\" controller regulates the distribution and accounting of\n RDMA resources.\n \n+When RDMA devices are isolated per network namespace (exclusive mode),\n+device names are unique only within a network namespace. The device lines\n+below are therefore scoped to the reading or writing process's network\n+namespace: only devices accessible from that namespace are listed, and a\n+limit is applied to the device of that name in that namespace. Configure\n+limits from the same network namespace as the workloads.\n+\n RDMA Interface Files\n ~~~~~~~~~~~~~~~~~~~~\n \ndiff --git a/drivers/infiniband/core/cgroup.c b/drivers/infiniband/core/cgroup.c\nindex 1f037fe01450ef..7a216ed45199bc 100644\n--- a/drivers/infiniband/core/cgroup.c\n+++ b/drivers/infiniband/core/cgroup.c\n@@ -17,6 +17,8 @@\n void ib_device_register_rdmacg(struct ib_device *device)\n {\n \tdevice-\u003ecg_device.name = device-\u003ename;\n+\tdevice-\u003ecg_device.netns_shared = ib_devices_shared_netns;\n+\twrite_pnet(\u0026device-\u003ecg_device.net, rdma_dev_net(device));\n \trdmacg_register_device(\u0026device-\u003ecg_device);\n }\n \n@@ -34,6 +36,16 @@ void ib_device_unregister_rdmacg(struct ib_device *device)\n \trdmacg_unregister_device(\u0026device-\u003ecg_device);\n }\n \n+void ib_device_rdmacg_change_netns(struct ib_device *device, struct net *net)\n+{\n+\twrite_pnet(\u0026device-\u003ecg_device.net, net);\n+}\n+\n+void ib_device_rdmacg_set_netns_shared(struct ib_device *device, bool shared)\n+{\n+\tWRITE_ONCE(device-\u003ecg_device.netns_shared, shared);\n+}\n+\n int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,\n \t\t\t struct ib_device *device,\n \t\t\t enum rdmacg_resource_type resource_index)\ndiff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c\nindex 891e52afb8f4ba..c389d4e37b6bcf 100644\n--- a/drivers/infiniband/core/cma_configfs.c\n+++ b/drivers/infiniband/core/cma_configfs.c\n@@ -65,6 +65,10 @@ static struct cma_dev_port_group *to_dev_port_group(struct config_item *item)\n \treturn container_of(group, struct cma_dev_port_group, group);\n }\n \n+/*\n+ * configfs is not net namespace aware, so a name shared by devices in\n+ * different namespaces resolves to the first match here.\n+ */\n static bool filter_by_name(struct ib_device *ib_dev, void *cookie)\n {\n \treturn !strcmp(dev_name(\u0026ib_dev-\u003edev), cookie);\ndiff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h\nindex 19104c542b270d..9cd671e2db2040 100644\n--- a/drivers/infiniband/core/core_priv.h\n+++ b/drivers/infiniband/core/core_priv.h\n@@ -156,6 +156,8 @@ void ib_dispatch_event_clients(struct ib_event *event);\n #ifdef CONFIG_CGROUP_RDMA\n void ib_device_register_rdmacg(struct ib_device *device);\n void ib_device_unregister_rdmacg(struct ib_device *device);\n+void ib_device_rdmacg_change_netns(struct ib_device *device, struct net *net);\n+void ib_device_rdmacg_set_netns_shared(struct ib_device *device, bool shared);\n \n int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,\n \t\t\t struct ib_device *device,\n@@ -173,6 +175,16 @@ static inline void ib_device_unregister_rdmacg(struct ib_device *device)\n {\n }\n \n+static inline void ib_device_rdmacg_change_netns(struct ib_device *device,\n+\t\t\t\t\t\t struct net *net)\n+{\n+}\n+\n+static inline void ib_device_rdmacg_set_netns_shared(struct ib_device *device,\n+\t\t\t\t\t\t bool shared)\n+{\n+}\n+\n static inline int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,\n \t\t\t\t struct ib_device *device,\n \t\t\t\t enum rdmacg_resource_type resource_index)\n@@ -356,7 +368,8 @@ void ib_port_unregister_client_groups(struct ib_device *ibdev, u32 port_num,\n \t\t\t\t const struct attribute_group **groups);\n \n int ib_device_set_netns_put(struct sk_buff *skb,\n-\t\t\t struct ib_device *dev, u32 ns_fd);\n+\t\t\t struct ib_device *dev, u32 ns_fd, const char *name,\n+\t\t\t struct netlink_ext_ack *extack);\n \n int rdma_nl_net_init(struct rdma_dev_net *rnet);\n void rdma_nl_net_exit(struct rdma_dev_net *rnet);\ndiff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c\nindex b8193e077a746f..cffb0de1c0016b 100644\n--- a/drivers/infiniband/core/device.c\n+++ b/drivers/infiniband/core/device.c\n@@ -129,7 +129,7 @@ static DECLARE_RWSEM(rdma_nets_rwsem);\n bool ib_devices_shared_netns = true;\n module_param_named(netns_mode, ib_devices_shared_netns, bool, 0444);\n MODULE_PARM_DESC(netns_mode,\n-\t\t \"Share device among net namespaces; default=1 (shared)\");\n+\t\t \"Share device among net namespaces; default=1 (shared). In exclusive mode device names are unique per net namespace\");\n /**\n * rdma_dev_access_netns() - Return whether an rdma device can be accessed\n *\t\t\t from a specified net namespace or not.\n@@ -268,7 +268,8 @@ static struct notifier_block ibdev_lsm_nb = {\n };\n \n static int rdma_dev_change_netns(struct ib_device *device, struct net *cur_net,\n-\t\t\t\t struct net *net);\n+\t\t\t\t struct net *net, const char *requested_name,\n+\t\t\t\t const char *fallback_pattern);\n \n /* Pointer to the RCU head at the start of the ib_port_data array */\n struct ib_port_data_rcu {\n@@ -351,13 +352,15 @@ void ib_device_put(struct ib_device *device)\n }\n EXPORT_SYMBOL(ib_device_put);\n \n-static struct ib_device *__ib_device_get_by_name(const char *name)\n+static struct ib_device *__ib_device_get_by_name(const char *name,\n+\t\t\t\t\t\t const struct net *net)\n {\n \tstruct ib_device *device;\n \tunsigned long index;\n \n \txa_for_each (\u0026devices, index, device)\n-\t\tif (!strcmp(name, dev_name(\u0026device-\u003edev)))\n+\t\tif (rdma_dev_access_netns(device, net) \u0026\u0026\n+\t\t !strcmp(name, dev_name(\u0026device-\u003edev)))\n \t\t\treturn device;\n \n \treturn NULL;\n@@ -395,7 +398,7 @@ int ib_device_rename(struct ib_device *ibdev, const char *name)\n \t\treturn 0;\n \t}\n \n-\tif (__ib_device_get_by_name(name)) {\n+\tif (__ib_device_get_by_name(name, rdma_dev_net(ibdev))) {\n \t\tup_write(\u0026devices_rwsem);\n \t\treturn -EEXIST;\n \t}\n@@ -435,7 +438,13 @@ int ib_device_set_dim(struct ib_device *ibdev, u8 use_dim)\n \treturn 0;\n }\n \n-static int alloc_name(struct ib_device *ibdev, const char *name)\n+/*\n+ * Pick a free index for the '%d' style @name pattern within net namespace\n+ * @net. Returns the index on success or a negative errno. The caller builds\n+ * the final unique device name from the returned index.\n+ */\n+static int __alloc_name_id(struct net *net, const char *name,\n+\t\t\t const struct ib_device *skip)\n {\n \tstruct ib_device *device;\n \tunsigned long index;\n@@ -448,6 +457,8 @@ static int alloc_name(struct ib_device *ibdev, const char *name)\n \txa_for_each (\u0026devices, index, device) {\n \t\tchar buf[IB_DEVICE_NAME_MAX];\n \n+\t\tif (device == skip || !rdma_dev_access_netns(device, net))\n+\t\t\tcontinue;\n \t\tif (sscanf(dev_name(\u0026device-\u003edev), name, \u0026i) != 1)\n \t\t\tcontinue;\n \t\tif (i \u003c 0 || i \u003e= INT_MAX)\n@@ -462,15 +473,27 @@ static int alloc_name(struct ib_device *ibdev, const char *name)\n \t}\n \n \trc = ida_alloc(\u0026inuse, GFP_KERNEL);\n-\tif (rc \u003c 0)\n-\t\tgoto out;\n-\n-\trc = dev_set_name(\u0026ibdev-\u003edev, name, rc);\n out:\n \tida_destroy(\u0026inuse);\n \treturn rc;\n }\n \n+static int alloc_name_id(struct net *net, const char *name)\n+{\n+\treturn __alloc_name_id(net, name, NULL);\n+}\n+\n+static int alloc_name(struct ib_device *ibdev, const char *name)\n+{\n+\tint id;\n+\n+\tid = alloc_name_id(rdma_dev_net(ibdev), name);\n+\tif (id \u003c 0)\n+\t\treturn id;\n+\n+\treturn dev_set_name(\u0026ibdev-\u003edev, name, id);\n+}\n+\n static void ib_device_release(struct device *device)\n {\n \tstruct ib_device *dev = container_of(device, struct ib_device, dev);\n@@ -1094,6 +1117,7 @@ static int add_all_compat_devs(void)\n int rdma_compatdev_set(u8 enable)\n {\n \tstruct rdma_dev_net *rnet;\n+\tstruct ib_device *dev;\n \tunsigned long index;\n \tint ret = 0;\n \n@@ -1116,6 +1140,12 @@ int rdma_compatdev_set(u8 enable)\n \tif (ret)\n \t\treturn -EBUSY;\n \n+\t/* Keep each registered device's rdma cgroup visibility in sync. */\n+\tdown_read(\u0026devices_rwsem);\n+\txa_for_each_marked(\u0026devices, index, dev, DEVICE_REGISTERED)\n+\t\tib_device_rdmacg_set_netns_shared(dev, enable);\n+\tup_read(\u0026devices_rwsem);\n+\n \tif (enable)\n \t\tret = add_all_compat_devs();\n \telse\n@@ -1151,8 +1181,17 @@ static void rdma_dev_exit_net(struct net *net)\n \n \t\t/*\n \t\t * If the real device is in the NS then move it back to init.\n+\t\t * Provide a fallback pattern so a name conflict in init_net\n+\t\t * cannot make the teardown move fail.\n \t\t */\n-\t\trdma_dev_change_netns(dev, net, \u0026init_net);\n+\t\tif (net_eq(net, read_pnet(\u0026dev-\u003ecoredev.rdma_net))) {\n+\t\t\tret = rdma_dev_change_netns(dev, net, \u0026init_net,\n+\t\t\t\t\t\t NULL, \"ibdev%d\");\n+\t\t\tif (ret)\n+\t\t\t\tWARN(1,\n+\t\t\t\t \"Failed to move RDMA device %s to init_net on netns exit: %d\\n\",\n+\t\t\t\t dev_name(\u0026dev-\u003edev), ret);\n+\t\t}\n \n \t\tput_device(\u0026dev-\u003edev);\n \t\tdown_read(\u0026devices_rwsem);\n@@ -1206,7 +1245,8 @@ static __net_init int rdma_dev_init_net(struct net *net)\n }\n \n /*\n- * Assign the unique string device name and the unique device index. This is\n+ * Assign the unique string device name and the unique device index. The device\n+ * name is unique within the net namespace the device is assigned to. This is\n * undone by ib_dealloc_device.\n */\n static int assign_name(struct ib_device *device, const char *name)\n@@ -1223,7 +1263,8 @@ static int assign_name(struct ib_device *device, const char *name)\n \tif (ret)\n \t\tgoto out;\n \n-\tif (__ib_device_get_by_name(dev_name(\u0026device-\u003edev))) {\n+\tif (__ib_device_get_by_name(dev_name(\u0026device-\u003edev),\n+\t\t\t\t rdma_dev_net(device))) {\n \t\tret = -ENFILE;\n \t\tgoto out;\n \t}\n@@ -1322,6 +1363,7 @@ static int enable_device_and_get(struct ib_device *device)\n \t */\n \trefcount_set(\u0026device-\u003erefcount, 2);\n \tdown_write(\u0026devices_rwsem);\n+\tib_device_rdmacg_set_netns_shared(device, ib_devices_shared_netns);\n \txa_set_mark(\u0026devices, device-\u003eindex, DEVICE_REGISTERED);\n \n \t/*\n@@ -1388,8 +1430,9 @@ static void ib_device_notify_register(struct ib_device *device)\n /**\n * ib_register_device - Register an IB device with IB core\n * @device: Device to register\n- * @name: unique string device name. This may include a '%' which will\n- * \t cause a unique index to be added to the passed device name.\n+ * @name: device name, unique within the device's net namespace. This may\n+ *\t include a '%' which will cause a unique index to be added to the\n+ *\t passed device name.\n * @dma_device: pointer to a DMA-capable device. If %NULL, then the IB\n *\t device will be used. In this case the caller should fully\n *\t\tsetup the ibdev for DMA. This usually means using dma_virt_ops.\n@@ -1670,14 +1713,83 @@ void ib_unregister_device_queued(struct ib_device *ib_dev)\n }\n EXPORT_SYMBOL(ib_unregister_device_queued);\n \n+static bool rdma_dev_name_in_netns(struct ib_device *skip, struct net *net,\n+\t\t\t\t const char *name)\n+{\n+\tstruct ib_device *device;\n+\tunsigned long index;\n+\n+\tlockdep_assert_held_write(\u0026devices_rwsem);\n+\n+\txa_for_each(\u0026devices, index, device)\n+\t\tif (device != skip \u0026\u0026\n+\t\t rdma_dev_access_netns(device, net) \u0026\u0026\n+\t\t !strcmp(name, dev_name(\u0026device-\u003edev)))\n+\t\t\treturn true;\n+\n+\treturn false;\n+}\n+\n+/*\n+ * Choose the name @device should use in net namespace @net. @requested_name\n+ * is used as a literal device name when set. Otherwise keep the current name\n+ * when it is free, or use a trusted '%d' @fallback_pattern for teardown. The\n+ * caller must hold the write side of devices_rwsem.\n+ */\n+static int rdma_dev_pick_netns_name(struct ib_device *device, struct net *net,\n+\t\t\t\t const char *requested_name,\n+\t\t\t\t const char *fallback_pattern,\n+\t\t\t\t char *buf, size_t buf_len,\n+\t\t\t\t const char **new_name)\n+{\n+\tint id;\n+\n+\tlockdep_assert_held_write(\u0026devices_rwsem);\n+\n+\tif (requested_name) {\n+\t\tif (!rdma_dev_name_in_netns(device, net, requested_name)) {\n+\t\t\t*new_name = requested_name;\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\treturn -EEXIST;\n+\t}\n+\n+\tif (!rdma_dev_name_in_netns(device, net, dev_name(\u0026device-\u003edev))) {\n+\t\t*new_name = dev_name(\u0026device-\u003edev);\n+\t\treturn 0;\n+\t}\n+\n+\tif (!fallback_pattern)\n+\t\treturn -EEXIST;\n+\n+\tsnprintf(buf, buf_len, \"ibdev%u\", device-\u003eindex);\n+\tif (!rdma_dev_name_in_netns(device, net, buf)) {\n+\t\t*new_name = buf;\n+\t\treturn 0;\n+\t}\n+\n+\tid = __alloc_name_id(net, fallback_pattern, device);\n+\tif (id \u003c 0)\n+\t\treturn id;\n+\tsnprintf(buf, buf_len, fallback_pattern, id);\n+\t*new_name = buf;\n+\treturn 0;\n+}\n+\n /*\n * The caller must pass in a device that has the kref held and the refcount\n * released. If the device is in cur_net and still registered then it is moved\n * into net.\n+ *\n+ * Naming rules are handled by rdma_dev_pick_netns_name().\n */\n static int rdma_dev_change_netns(struct ib_device *device, struct net *cur_net,\n-\t\t\t\t struct net *net)\n+\t\t\t\t struct net *net, const char *requested_name,\n+\t\t\t\t const char *fallback_pattern)\n {\n+\tchar buf[IB_DEVICE_NAME_MAX];\n+\tconst char *new_name;\n \tint ret2 = -EINVAL;\n \tint ret;\n \n@@ -1694,30 +1806,68 @@ static int rdma_dev_change_netns(struct ib_device *device, struct net *cur_net,\n \t\tgoto out;\n \t}\n \n+\tif (!fallback_pattern) {\n+\t\t/*\n+\t\t * Reject a predictable name conflict before tearing anything\n+\t\t * down, so a doomed user move does not disable a live device.\n+\t\t */\n+\t\tdown_write(\u0026devices_rwsem);\n+\t\tret = rdma_dev_pick_netns_name(device, net, requested_name,\n+\t\t\t\t\t fallback_pattern, buf,\n+\t\t\t\t\t sizeof(buf), \u0026new_name);\n+\t\tup_write(\u0026devices_rwsem);\n+\t\tif (ret)\n+\t\t\tgoto out;\n+\t}\n+\n \tkobject_uevent(\u0026device-\u003edev.kobj, KOBJ_REMOVE);\n \tdisable_device(device);\n \n \t/*\n-\t * At this point no one can be using the device, so it is safe to\n-\t * change the namespace.\n+\t * Recompute the destination name under the write side of devices_rwsem\n+\t * now that the device is disabled, closing races with a concurrent\n+\t * registration or rename, then publish the new namespace at the sysfs\n+\t * level.\n \t */\n-\twrite_pnet(\u0026device-\u003ecoredev.rdma_net, net);\n+\tdown_write(\u0026devices_rwsem);\n+\tret = rdma_dev_pick_netns_name(device, net, requested_name,\n+\t\t\t\t fallback_pattern, buf, sizeof(buf),\n+\t\t\t\t \u0026new_name);\n+\tif (ret) {\n+\t\tif (fallback_pattern) {\n+\t\t\tWARN(1,\n+\t\t\t \"%s: failed to pick device name during namespace teardown: %d\\n\",\n+\t\t\t __func__, ret);\n+\t\t\twrite_pnet(\u0026device-\u003ecoredev.rdma_net, net);\n+\t\t\tib_device_rdmacg_change_netns(device, net);\n+\t\t\tret = 0;\n+\t\t}\n+\t\tgoto rename_done;\n+\t}\n \n-\tdown_read(\u0026devices_rwsem);\n-\t/*\n-\t * Currently rdma devices are system wide unique. So the device name\n-\t * is guaranteed free in the new namespace. Publish the new namespace\n-\t * at the sysfs level.\n-\t */\n-\tret = device_rename(\u0026device-\u003edev, dev_name(\u0026device-\u003edev));\n-\tup_read(\u0026devices_rwsem);\n+\twrite_pnet(\u0026device-\u003ecoredev.rdma_net, net);\n+\tib_device_rdmacg_change_netns(device, net);\n+\tret = device_rename(\u0026device-\u003edev, new_name);\n \tif (ret) {\n-\t\tdev_warn(\u0026device-\u003edev,\n-\t\t\t \"%s: Couldn't rename device after namespace change\\n\",\n-\t\t\t __func__);\n-\t\t/* Try and put things back and re-enable the device */\n-\t\twrite_pnet(\u0026device-\u003ecoredev.rdma_net, cur_net);\n+\t\tif (fallback_pattern) {\n+\t\t\tWARN(1,\n+\t\t\t \"%s: failed to rename device during namespace teardown: %d\\n\",\n+\t\t\t __func__, ret);\n+\t\t\tret = 0;\n+\t\t} else {\n+\t\t\tdev_warn(\u0026device-\u003edev,\n+\t\t\t\t \"%s: Couldn't rename device after namespace change\\n\",\n+\t\t\t\t __func__);\n+\t\t\t/* Try and put things back and re-enable the device */\n+\t\t\twrite_pnet(\u0026device-\u003ecoredev.rdma_net, cur_net);\n+\t\t\tib_device_rdmacg_change_netns(device, cur_net);\n+\t\t}\n+\t} else {\n+\t\tstrscpy(device-\u003ename, dev_name(\u0026device-\u003edev),\n+\t\t\tIB_DEVICE_NAME_MAX);\n \t}\n+rename_done:\n+\tup_write(\u0026devices_rwsem);\n \n \tret2 = enable_device_and_get(device);\n \tif (ret2) {\n@@ -1740,36 +1890,72 @@ static int rdma_dev_change_netns(struct ib_device *device, struct net *cur_net,\n }\n \n int ib_device_set_netns_put(struct sk_buff *skb,\n-\t\t\t struct ib_device *dev, u32 ns_fd)\n+\t\t\t struct ib_device *dev, u32 ns_fd, const char *name,\n+\t\t\t struct netlink_ext_ack *extack)\n {\n \tstruct net *net;\n \tint ret;\n \n \tnet = get_net_ns_by_fd(ns_fd);\n \tif (IS_ERR(net)) {\n+\t\tNL_SET_ERR_MSG(extack, \"Invalid target net namespace fd\");\n \t\tret = PTR_ERR(net);\n \t\tgoto net_err;\n \t}\n \n \tif (!netlink_ns_capable(skb, net-\u003euser_ns, CAP_NET_ADMIN)) {\n+\t\tNL_SET_ERR_MSG(extack,\n+\t\t\t \"Missing CAP_NET_ADMIN in the target net namespace\");\n \t\tret = -EPERM;\n \t\tgoto ns_err;\n \t}\n \n+\t/*\n+\t * Moving a device to the namespace it already lives in is a no-op; a\n+\t * supplied name still renames it in place.\n+\t */\n+\tif (net_eq(net, read_pnet(\u0026dev-\u003ecoredev.rdma_net))) {\n+\t\tret = name ? ib_device_rename(dev, name) : 0;\n+\n+\t\tif (ret == -EEXIST)\n+\t\t\tNL_SET_ERR_MSG(extack,\n+\t\t\t\t \"Device name already exists in the target net namespace\");\n+\t\telse if (ret == -EINVAL \u0026\u0026 name)\n+\t\t\tNL_SET_ERR_MSG(extack,\n+\t\t\t\t \"Unable to use requested device name in the target net namespace\");\n+\t\tgoto ns_err;\n+\t}\n+\n \t/*\n \t * All the ib_clients, including uverbs, are reset when the namespace is\n \t * changed and this cannot be blocked waiting for userspace to do\n \t * something, so disassociation is mandatory.\n \t */\n-\tif (!dev-\u003eops.disassociate_ucontext || ib_devices_shared_netns) {\n+\tif (ib_devices_shared_netns) {\n+\t\tNL_SET_ERR_MSG(extack,\n+\t\t\t \"Cannot change net namespace of RDMA device in shared netns mode\");\n+\t\tret = -EOPNOTSUPP;\n+\t\tgoto ns_err;\n+\t}\n+\n+\tif (!dev-\u003eops.disassociate_ucontext) {\n+\t\tNL_SET_ERR_MSG(extack,\n+\t\t\t \"Device does not support namespace changes (no disassociate support)\");\n \t\tret = -EOPNOTSUPP;\n \t\tgoto ns_err;\n \t}\n \n \tget_device(\u0026dev-\u003edev);\n \tib_device_put(dev);\n-\tret = rdma_dev_change_netns(dev, current-\u003ensproxy-\u003enet_ns, net);\n+\tret = rdma_dev_change_netns(dev, current-\u003ensproxy-\u003enet_ns, net, name,\n+\t\t\t\t NULL);\n \tput_device(\u0026dev-\u003edev);\n+\tif (ret == -EEXIST)\n+\t\tNL_SET_ERR_MSG(extack,\n+\t\t\t \"Device name already exists in the target net namespace\");\n+\telse if (ret == -EINVAL \u0026\u0026 name)\n+\t\tNL_SET_ERR_MSG(extack,\n+\t\t\t \"Unable to use requested device name in the target net namespace\");\n \n \tput_net(net);\n \treturn ret;\ndiff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c\nindex f599c24b34e81b..473bf9667f83e6 100644\n--- a/drivers/infiniband/core/nldev.c\n+++ b/drivers/infiniband/core/nldev.c\n@@ -1177,6 +1177,24 @@ static int nldev_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,\n \tif (!device)\n \t\treturn -EINVAL;\n \n+\tif (tb[RDMA_NLDEV_NET_NS_FD]) {\n+\t\tchar name[IB_DEVICE_NAME_MAX] = {};\n+\t\tu32 ns_fd;\n+\n+\t\tif (tb[RDMA_NLDEV_ATTR_DEV_NAME]) {\n+\t\t\tnla_strscpy(name, tb[RDMA_NLDEV_ATTR_DEV_NAME],\n+\t\t\t\t IB_DEVICE_NAME_MAX);\n+\t\t\tif (strlen(name) == 0) {\n+\t\t\t\terr = -EINVAL;\n+\t\t\t\tgoto done;\n+\t\t\t}\n+\t\t}\n+\t\tns_fd = nla_get_u32(tb[RDMA_NLDEV_NET_NS_FD]);\n+\t\terr = ib_device_set_netns_put(skb, device, ns_fd,\n+\t\t\t\t\t name[0] ? name : NULL, extack);\n+\t\tgoto put_done;\n+\t}\n+\n \tif (tb[RDMA_NLDEV_ATTR_DEV_NAME]) {\n \t\tchar name[IB_DEVICE_NAME_MAX] = {};\n \n@@ -1190,14 +1208,6 @@ static int nldev_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,\n \t\tgoto done;\n \t}\n \n-\tif (tb[RDMA_NLDEV_NET_NS_FD]) {\n-\t\tu32 ns_fd;\n-\n-\t\tns_fd = nla_get_u32(tb[RDMA_NLDEV_NET_NS_FD]);\n-\t\terr = ib_device_set_netns_put(skb, device, ns_fd);\n-\t\tgoto put_done;\n-\t}\n-\n \tif (tb[RDMA_NLDEV_ATTR_DEV_DIM]) {\n \t\tu8 use_dim;\n \ndiff --git a/drivers/infiniband/core/security.c b/drivers/infiniband/core/security.c\nindex 9af31d1d9d70c7..a82c46965416a1 100644\n--- a/drivers/infiniband/core/security.c\n+++ b/drivers/infiniband/core/security.c\n@@ -700,6 +700,12 @@ int ib_mad_agent_security_setup(struct ib_mad_agent *agent,\n \tif (qp_type != IB_QPT_SMI)\n \t\treturn 0;\n \n+\t/*\n+\t * SELinux labels an endport by (device name, port) from a global\n+\t * policy. If devices in different net namespaces share a name, they get\n+\t * the same label; distinguishing them would need net namespace support\n+\t * in the policy language and tooling.\n+\t */\n \tspin_lock(\u0026mad_agent_list_lock);\n \tret = security_ib_endport_manage_subnet(agent-\u003esecurity,\n \t\t\t\t\t\tdev_name(\u0026agent-\u003edevice-\u003edev),\ndiff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c\nindex 1ec130fee8ea7a..6eb10d2f0653bc 100644\n--- a/drivers/infiniband/sw/rxe/rxe_verbs.c\n+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c\n@@ -240,6 +240,10 @@ static void rxe_dealloc_ucontext(struct ib_ucontext *ibuc)\n \t\trxe_err_uc(uc, \"cleanup failed, err = %d\\n\", err);\n }\n \n+static void rxe_disassociate_ucontext(struct ib_ucontext *ibuc)\n+{\n+}\n+\n /* pd */\n static int rxe_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)\n {\n@@ -1478,6 +1482,7 @@ static const struct ib_device_ops rxe_dev_ops = {\n \t.destroy_srq = rxe_destroy_srq,\n \t.detach_mcast = rxe_detach_mcast,\n \t.device_group = \u0026rxe_attr_group,\n+\t.disassociate_ucontext = rxe_disassociate_ucontext,\n \t.enable_driver = rxe_enable_driver,\n \t.get_dma_mr = rxe_get_dma_mr,\n \t.get_hw_stats = rxe_ib_get_hw_stats,\ndiff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c\nindex acbd787de265b5..a070fcf86e8a66 100644\n--- a/drivers/infiniband/ulp/srp/ib_srp.c\n+++ b/drivers/infiniband/ulp/srp/ib_srp.c\n@@ -3189,10 +3189,24 @@ static struct attribute *srp_class_attrs[];\n \n ATTRIBUTE_GROUPS(srp_class);\n \n+/*\n+ * SRP hosts are named after their ib device, so tag the class by the ib\n+ * device's net namespace.\n+ */\n+static const struct ns_common *srp_net_namespace(const struct device *dev)\n+{\n+\tstruct srp_host *host = container_of(dev, struct srp_host, dev);\n+\tstruct net *net = rdma_dev_net(host-\u003esrp_dev-\u003edev);\n+\n+\treturn net ? to_ns_common(net) : NULL;\n+}\n+\n static struct class srp_class = {\n \t.name = \"infiniband_srp\",\n \t.dev_groups = srp_class_groups,\n-\t.dev_release = srp_release_dev\n+\t.dev_release = srp_release_dev,\n+\t.ns_type = \u0026net_ns_type_operations,\n+\t.namespace = srp_net_namespace,\n };\n \n /**\ndiff --git a/include/linux/cgroup_rdma.h b/include/linux/cgroup_rdma.h\nindex 404e746552ca8f..71170cb0e19e34 100644\n--- a/include/linux/cgroup_rdma.h\n+++ b/include/linux/cgroup_rdma.h\n@@ -7,6 +7,7 @@\n #define _CGROUP_RDMA_H\n \n #include \u003clinux/cgroup.h\u003e\n+#include \u003cnet/net_namespace.h\u003e\n \n enum rdmacg_resource_type {\n \tRDMACG_RESOURCE_HCA_HANDLE,\n@@ -34,6 +35,15 @@ struct rdmacg_device {\n \tstruct list_head\tdev_node;\n \tstruct list_head\trpools;\n \tchar\t\t\t*name;\n+\t/*\n+\t * Net namespace the device belongs to. @netns_shared mirrors\n+\t * ib_devices_shared_netns: when true the device is visible from every\n+\t * net namespace (shared mode); otherwise @net is the only namespace\n+\t * that may see and configure it. @netns_shared is updated when the\n+\t * sharing mode changes, so use {READ,WRITE}_ONCE() to access it.\n+\t */\n+\tpossible_net_t\t\tnet;\n+\tbool\t\t\tnetns_shared;\n };\n \n /*\ndiff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h\nindex 3af946ecbac3ed..ee11c3bbbae22a 100644\n--- a/include/uapi/rdma/rdma_netlink.h\n+++ b/include/uapi/rdma/rdma_netlink.h\n@@ -516,7 +516,10 @@ enum rdma_nldev_attr {\n \tRDMA_NLDEV_ATTR_DEV_PROTOCOL,\t\t/* string */\n \n \t/*\n-\t * File descriptor handle of the net namespace object\n+\t * File descriptor handle of the net namespace object. May be combined\n+\t * with RDMA_NLDEV_ATTR_DEV_NAME (a literal device name) to also rename\n+\t * the device in the destination namespace; the move fails with -EEXIST\n+\t * if that name is already taken there.\n \t */\n \tRDMA_NLDEV_NET_NS_FD,\t\t\t/* u32 */\n \t/*\ndiff --git a/kernel/cgroup/rdma.c b/kernel/cgroup/rdma.c\nindex 5e82a03b3270ad..c8b4e3de763051 100644\n--- a/kernel/cgroup/rdma.c\n+++ b/kernel/cgroup/rdma.c\n@@ -15,6 +15,7 @@\n #include \u003clinux/cgroup.h\u003e\n #include \u003clinux/parser.h\u003e\n #include \u003clinux/cgroup_rdma.h\u003e\n+#include \u003clinux/nsproxy.h\u003e\n \n #define RDMACG_MAX_STR \"max\"\n \n@@ -464,6 +465,13 @@ void rdmacg_unregister_device(struct rdmacg_device *device)\n }\n EXPORT_SYMBOL(rdmacg_unregister_device);\n \n+/* netns_shared is toggled without rdmacg_mutex, hence READ_ONCE(). */\n+static bool rdmacg_device_visible(const struct rdmacg_device *device)\n+{\n+\treturn READ_ONCE(device-\u003enetns_shared) ||\n+\t net_eq(read_pnet(\u0026device-\u003enet), current-\u003ensproxy-\u003enet_ns);\n+}\n+\n static struct rdmacg_device *rdmacg_get_device_locked(const char *name)\n {\n \tstruct rdmacg_device *device;\n@@ -471,7 +479,8 @@ static struct rdmacg_device *rdmacg_get_device_locked(const char *name)\n \tlockdep_assert_held(\u0026rdmacg_mutex);\n \n \tlist_for_each_entry(device, \u0026rdmacg_devices, dev_node)\n-\t\tif (!strcmp(name, device-\u003ename))\n+\t\tif (rdmacg_device_visible(device) \u0026\u0026\n+\t\t !strcmp(name, device-\u003ename))\n \t\t\treturn device;\n \n \treturn NULL;\n@@ -626,6 +635,9 @@ static int rdmacg_resource_read(struct seq_file *sf, void *v)\n \tmutex_lock(\u0026rdmacg_mutex);\n \n \tlist_for_each_entry(device, \u0026rdmacg_devices, dev_node) {\n+\t\tif (!rdmacg_device_visible(device))\n+\t\t\tcontinue;\n+\n \t\tseq_printf(sf, \"%s \", device-\u003ename);\n \n \t\trpool = find_cg_rpool_locked(cg, device);\n@@ -648,6 +660,9 @@ static int rdmacg_events_show(struct seq_file *sf, void *v)\n \tmutex_lock(\u0026rdmacg_mutex);\n \n \tlist_for_each_entry(device, \u0026rdmacg_devices, dev_node) {\n+\t\tif (!rdmacg_device_visible(device))\n+\t\t\tcontinue;\n+\n \t\trpool = find_cg_rpool_locked(cg, device);\n \n \t\tseq_printf(sf, \"%s \", device-\u003ename);\n@@ -677,6 +692,9 @@ static int rdmacg_events_local_show(struct seq_file *sf, void *v)\n \tmutex_lock(\u0026rdmacg_mutex);\n \n \tlist_for_each_entry(device, \u0026rdmacg_devices, dev_node) {\n+\t\tif (!rdmacg_device_visible(device))\n+\t\t\tcontinue;\n+\n \t\trpool = find_cg_rpool_locked(cg, device);\n \n \t\tseq_printf(sf, \"%s \", device-\u003ename);\ndiff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c\nindex 63e286e2dfaa8d..ff9c9c35cc2f5b 100644\n--- a/net/smc/smc_pnet.c\n+++ b/net/smc/smc_pnet.c\n@@ -304,13 +304,18 @@ static bool smc_pnetid_valid(const char *pnet_name, char *pnetid)\n \treturn true;\n }\n \n-/* Find an infiniband device by a given name. The device might not exist. */\n-static struct smc_ib_device *smc_pnet_find_ib(char *ib_name)\n+/*\n+ * Find an infiniband device by a given name, restricted to the devices\n+ * accessible from @net. The device might not exist.\n+ */\n+static struct smc_ib_device *smc_pnet_find_ib(struct net *net, char *ib_name)\n {\n \tstruct smc_ib_device *ibdev;\n \n \tmutex_lock(\u0026smc_ib_devices.mutex);\n \tlist_for_each_entry(ibdev, \u0026smc_ib_devices.list, list) {\n+\t\tif (!rdma_dev_access_netns(ibdev-\u003eibdev, net))\n+\t\t\tcontinue;\n \t\tif (!strncmp(ibdev-\u003eibdev-\u003ename, ib_name,\n \t\t\t sizeof(ibdev-\u003eibdev-\u003ename)) ||\n \t\t (ibdev-\u003eibdev-\u003edev.parent \u0026\u0026\n@@ -408,8 +413,8 @@ static int smc_pnet_add_eth(struct smc_pnettable *pnettable, struct net *net,\n \treturn rc;\n }\n \n-static int smc_pnet_add_ib(struct smc_pnettable *pnettable, char *ib_name,\n-\t\t\t u8 ib_port, char *pnet_name)\n+static int smc_pnet_add_ib(struct smc_pnettable *pnettable, struct net *net,\n+\t\t\t char *ib_name, u8 ib_port, char *pnet_name)\n {\n \tstruct smc_pnetentry *tmp_pe, *new_pe;\n \tstruct smc_ib_device *ib_dev;\n@@ -419,7 +424,7 @@ static int smc_pnet_add_ib(struct smc_pnettable *pnettable, char *ib_name,\n \tbool new_ibdev;\n \n \t/* try to apply the pnetid to active devices */\n-\tib_dev = smc_pnet_find_ib(ib_name);\n+\tib_dev = smc_pnet_find_ib(net, ib_name);\n \tif (ib_dev) {\n \t\tibdev_applied = smc_pnet_apply_ib(ib_dev, ib_port, pnet_name);\n \t\tif (ibdev_applied)\n@@ -518,7 +523,7 @@ static int smc_pnet_enter(struct net *net, struct nlattr *tb[])\n \t\t\tif (ibport \u003c 1 || ibport \u003e SMC_MAX_PORTS)\n \t\t\t\tgoto error;\n \t\t}\n-\t\trc = smc_pnet_add_ib(pnettable, string, ibport, pnet_name);\n+\t\trc = smc_pnet_add_ib(pnettable, net, string, ibport, pnet_name);\n \t\tif (!rc)\n \t\t\tnew_ibdev = true;\n \t\telse if (rc != -EEXIST)\n@@ -1170,6 +1175,9 @@ int smc_pnetid_by_table_ib(struct smc_ib_device *smcibdev, u8 ib_port)\n \tstruct smc_net *sn;\n \tint rc = -ENOENT;\n \n+\tif (!rdma_dev_access_netns(smcibdev-\u003eibdev, \u0026init_net))\n+\t\treturn -ENOENT;\n+\n \t/* get pnettable for init namespace */\n \tsn = net_generic(\u0026init_net, smc_net_id);\n \tpnettable = \u0026sn-\u003epnettable;\ndiff --git a/tools/testing/selftests/rdma/Makefile b/tools/testing/selftests/rdma/Makefile\nindex 07af7f15c1bf74..a91c14c45006e3 100644\n--- a/tools/testing/selftests/rdma/Makefile\n+++ b/tools/testing/selftests/rdma/Makefile\n@@ -3,6 +3,7 @@ TEST_PROGS := rxe_rping_between_netns.sh \\\n \t\trxe_ipv6.sh \\\n \t\trxe_socket_with_netns.sh \\\n \t\trxe_test_NETDEV_UNREGISTER.sh \\\n-\t\trxe_sent_rcvd_bytes.sh\n+\t\trxe_sent_rcvd_bytes.sh \\\n+\t\trxe_netns_names.sh\n \n include ../lib.mk\ndiff --git a/tools/testing/selftests/rdma/config b/tools/testing/selftests/rdma/config\nindex 4ffb814e253bbd..e1ff54ec0f5790 100644\n--- a/tools/testing/selftests/rdma/config\n+++ b/tools/testing/selftests/rdma/config\n@@ -1,3 +1,5 @@\n CONFIG_TUN\n CONFIG_VETH\n+CONFIG_DUMMY\n+CONFIG_NET_NS\n CONFIG_RDMA_RXE\ndiff --git a/tools/testing/selftests/rdma/rxe_netns_names.sh b/tools/testing/selftests/rdma/rxe_netns_names.sh\nnew file mode 100755\nindex 00000000000000..a7e57706fdff75\n--- /dev/null\n+++ b/tools/testing/selftests/rdma/rxe_netns_names.sh\n@@ -0,0 +1,282 @@\n+#!/bin/bash\n+# SPDX-License-Identifier: GPL-2.0\n+#\n+# Exercise RDMA device name handling across network namespaces.\n+\n+source \"$(dirname \"$0\")/../kselftest/ktap_helpers.sh\"\n+\n+NAME_PREFIX=\"rxe_netns_names_$$\"\n+NETDEV_PREFIX=\"rxn$$\"\n+NS1=\"${NAME_PREFIX}ns1\"\n+NS2=\"${NAME_PREFIX}ns2\"\n+RXE_A=\"${NAME_PREFIX}rxe_a\"\n+RXE_B=\"${NAME_PREFIX}rxe_b\"\n+RXE_SAME=\"${NAME_PREFIX}rxe_same\"\n+RXE_NEW=\"${NAME_PREFIX}rxe_new\"\n+DUMMY_A=\"${NETDEV_PREFIX}a\"\n+DUMMY_B=\"${NETDEV_PREFIX}b\"\n+OLD_MODE=\"\"\n+MODE_CHANGED=0\n+MODS=(\"dummy\" \"rdma_rxe\")\n+TEST_SAME_NAMES=\"same RDMA device name can exist in two net namespaces\"\n+TEST_MOVE_CONFLICT=\"move without rename fails on destination name conflict\"\n+TEST_MOVE_RENAME=\"move then rename succeeds\"\n+TEST_COMBINED_MOVE_RENAME=\"move with requested destination name succeeds\"\n+TEST_SAME_NETNS_DUP_RENAME=\"same-netns rename rejects duplicate name\"\n+TEST_TEARDOWN_RETURN=\"netns delete returns device to init_net and renames on conflict\"\n+\n+ksft_skip()\n+{\n+\tktap_skip_all \"$*\"\n+\texit \"$KSFT_SKIP\"\n+}\n+\n+fail()\n+{\n+\tktap_exit_fail_msg \"$*\"\n+}\n+\n+need_cmd()\n+{\n+\tcommand -v \"$1\" \u003e/dev/null 2\u003e\u00261 || ksft_skip \"missing command: $1\"\n+}\n+\n+rdma_ns()\n+{\n+\tlocal ns=$1\n+\n+\tshift\n+\tip netns exec \"$ns\" rdma \"$@\"\n+}\n+\n+rdma_dev_exists()\n+{\n+\tlocal ns=$1\n+\tlocal dev=$2\n+\n+\tif [ -n \"$ns\" ]; then\n+\t\trdma_ns \"$ns\" dev show \"$dev\" \u003e/dev/null 2\u003e\u00261\n+\telse\n+\t\trdma dev show \"$dev\" \u003e/dev/null 2\u003e\u00261\n+\tfi\n+}\n+\n+add_dummy()\n+{\n+\tlocal netdev=$1\n+\n+\tip link add \"$netdev\" type dummy || return 1\n+\tip link set \"$netdev\" up || return 1\n+}\n+\n+add_rxe()\n+{\n+\tlocal dev=$1\n+\tlocal netdev=$2\n+\n+\trdma link add \"$dev\" type rxe netdev \"$netdev\"\n+}\n+\n+rdma_dev_on_netdev()\n+{\n+\tlocal netdev=$1\n+\n+\trdma link show 2\u003e/dev/null | awk -v want=\"$netdev\" '\n+\t\t{\n+\t\t\tfor (i = 1; i \u003c NF; i++)\n+\t\t\t\tif ($i == \"netdev\" \u0026\u0026 $(i + 1) == want) {\n+\t\t\t\t\tdev = $2\n+\t\t\t\t\tsub(/\\/.*/, \"\", dev)\n+\t\t\t\t\tprint dev\n+\t\t\t\t\texit\n+\t\t\t\t}\n+\t\t}'\n+}\n+\n+wait_rdma_dev_on_netdev()\n+{\n+\tlocal netdev=$1\n+\tlocal dev\n+\tlocal i\n+\n+\tfor i in $(seq 1 50); do\n+\t\tdev=$(rdma_dev_on_netdev \"$netdev\")\n+\t\tif [ -n \"$dev\" ]; then\n+\t\t\techo \"$dev\"\n+\t\t\treturn 0\n+\t\tfi\n+\t\tsleep 0.1\n+\tdone\n+\n+\treturn 1\n+}\n+\n+setup_devs()\n+{\n+\tcleanup_devs\n+\n+\tadd_dummy \"$DUMMY_A\" || return 1\n+\tadd_dummy \"$DUMMY_B\" || return 1\n+\n+\tadd_rxe \"$RXE_A\" \"$DUMMY_A\" || return 1\n+\tadd_rxe \"$RXE_B\" \"$DUMMY_B\" || return 1\n+}\n+\n+cleanup_devs()\n+{\n+\tip link del \"$DUMMY_A\" 2\u003e/dev/null\n+\tip link del \"$DUMMY_B\" 2\u003e/dev/null\n+}\n+\n+setup()\n+{\n+\tOLD_MODE=$(rdma system show 2\u003e/dev/null |\n+\t\t sed -n 's/.*netns \\([^ ]*\\).*/\\1/p')\n+\t[ -n \"$OLD_MODE\" ] || ksft_skip \"failed to read RDMA netns mode\"\n+\n+\trdma system set netns exclusive \u003e/dev/null 2\u003e\u00261 ||\n+\t\tksft_skip \"rdma netns exclusive mode is not supported\"\n+\tMODE_CHANGED=1\n+\n+\tip netns add \"$NS1\" || return 1\n+\tip netns add \"$NS2\" || return 1\n+}\n+\n+cleanup()\n+{\n+\tcleanup_devs\n+\n+\tip netns del \"$NS1\" 2\u003e/dev/null\n+\tip netns del \"$NS2\" 2\u003e/dev/null\n+\n+\tif [ \"$MODE_CHANGED\" -eq 1 ]; then\n+\t\trdma system set netns \"$OLD_MODE\" 2\u003e/dev/null\n+\tfi\n+\n+\tfor m in \"${MODS[@]}\"; do\n+\t\tmodprobe -r \"$m\" 2\u003e/dev/null\n+\tdone\n+}\n+\n+rdma_supports_combined_move_rename()\n+{\n+\trdma dev help 2\u003e\u00261 | grep -Eq 'netns .*name|name .*netns'\n+}\n+\n+[ \"$(id -u)\" -eq 0 ] || ksft_skip \"must be run as root\"\n+need_cmd ip\n+need_cmd rdma\n+need_cmd modprobe\n+\n+trap cleanup EXIT\n+\n+for m in \"${MODS[@]}\"; do\n+\tmodinfo \"$m\" \u003e/dev/null 2\u003e\u00261 || ksft_skip \"module $m not found\"\n+\tmodprobe \"$m\" || fail \"failed to load $m\"\n+done\n+\n+setup || fail \"failed to create net namespaces\"\n+\n+ktap_print_header\n+ktap_set_plan 7\n+\n+if setup_devs \u0026\u0026\n+ rdma dev set \"$RXE_A\" netns \"$NS1\" \u0026\u0026\n+ rdma_ns \"$NS1\" dev set \"$RXE_A\" name \"$RXE_SAME\" \u0026\u0026\n+ rdma dev set \"$RXE_B\" netns \"$NS2\" \u0026\u0026\n+ rdma_ns \"$NS2\" dev set \"$RXE_B\" name \"$RXE_SAME\" \u0026\u0026\n+ rdma_dev_exists \"$NS1\" \"$RXE_SAME\" \u0026\u0026\n+ rdma_dev_exists \"$NS2\" \"$RXE_SAME\"; then\n+\tktap_test_pass \"$TEST_SAME_NAMES\"\n+else\n+\tktap_test_fail \"$TEST_SAME_NAMES\"\n+fi\n+cleanup_devs\n+\n+if ! setup_devs ||\n+ ! rdma dev set \"$RXE_A\" netns \"$NS1\" ||\n+ ! rdma_ns \"$NS1\" dev set \"$RXE_A\" name \"$RXE_SAME\" ||\n+ ! rdma dev set \"$RXE_B\" netns \"$NS2\" ||\n+ ! rdma_ns \"$NS2\" dev set \"$RXE_B\" name \"$RXE_SAME\"; then\n+\tktap_test_fail \"$TEST_MOVE_CONFLICT\"\n+elif rdma_ns \"$NS1\" dev set \"$RXE_SAME\" netns \"$NS2\" \u003e/dev/null 2\u003e\u00261; then\n+\tktap_test_fail \"$TEST_MOVE_CONFLICT\"\n+elif rdma_dev_exists \"$NS1\" \"$RXE_SAME\" \u0026\u0026\n+ rdma_dev_exists \"$NS2\" \"$RXE_SAME\"; then\n+\tktap_test_pass \"$TEST_MOVE_CONFLICT\"\n+else\n+\tktap_test_fail \"$TEST_MOVE_CONFLICT\"\n+fi\n+cleanup_devs\n+\n+if ! setup_devs; then\n+\tktap_test_fail \"$TEST_MOVE_RENAME\"\n+elif rdma dev set \"$RXE_A\" netns \"$NS2\" \u0026\u0026\n+ rdma_ns \"$NS2\" dev set \"$RXE_A\" name \"$RXE_NEW\"; then\n+\tif rdma_dev_exists \"$NS2\" \"$RXE_NEW\" \u0026\u0026\n+\t ! rdma_dev_exists \"\" \"$RXE_A\"; then\n+\t\tktap_test_pass \"$TEST_MOVE_RENAME\"\n+\telse\n+\t\tktap_test_fail \"$TEST_MOVE_RENAME\"\n+\tfi\n+else\n+\tktap_test_fail \"$TEST_MOVE_RENAME\"\n+fi\n+cleanup_devs\n+\n+if ! rdma_supports_combined_move_rename; then\n+\tktap_test_skip \"$TEST_COMBINED_MOVE_RENAME\"\n+elif ! setup_devs; then\n+\tktap_test_fail \"$TEST_COMBINED_MOVE_RENAME\"\n+elif rdma dev set \"$RXE_A\" netns \"$NS2\" name \"$RXE_NEW\"; then\n+\tif rdma_dev_exists \"$NS2\" \"$RXE_NEW\" \u0026\u0026\n+\t ! rdma_dev_exists \"\" \"$RXE_A\"; then\n+\t\tktap_test_pass \"$TEST_COMBINED_MOVE_RENAME\"\n+\telse\n+\t\tktap_test_fail \"$TEST_COMBINED_MOVE_RENAME\"\n+\tfi\n+else\n+\tktap_test_fail \"$TEST_COMBINED_MOVE_RENAME\"\n+fi\n+cleanup_devs\n+\n+if ! setup_devs; then\n+\tktap_test_fail \"$TEST_SAME_NETNS_DUP_RENAME\"\n+elif rdma dev set \"$RXE_A\" name \"$RXE_SAME\" \u0026\u0026\n+ rdma dev set \"$RXE_B\" name \"$RXE_NEW\"; then\n+\tif rdma dev set \"$RXE_A\" name \"$RXE_NEW\" \u003e/dev/null 2\u003e\u00261; then\n+\t\tktap_test_fail \"$TEST_SAME_NETNS_DUP_RENAME\"\n+\telif rdma_dev_exists \"\" \"$RXE_SAME\" \u0026\u0026\n+\t rdma_dev_exists \"\" \"$RXE_NEW\"; then\n+\t\tktap_test_pass \"$TEST_SAME_NETNS_DUP_RENAME\"\n+\telse\n+\t\tktap_test_fail \"$TEST_SAME_NETNS_DUP_RENAME\"\n+\tfi\n+else\n+\tktap_test_fail \"$TEST_SAME_NETNS_DUP_RENAME\"\n+fi\n+cleanup_devs\n+\n+if ! setup_devs; then\n+\tktap_test_fail \"$TEST_TEARDOWN_RETURN\"\n+elif ! rdma dev set \"$RXE_A\" name \"$RXE_SAME\" ||\n+ ! rdma dev set \"$RXE_B\" netns \"$NS2\" ||\n+ ! rdma_ns \"$NS2\" dev set \"$RXE_B\" name \"$RXE_SAME\" ||\n+ ! rdma_dev_exists \"$NS2\" \"$RXE_SAME\"; then\n+\tktap_test_fail \"$TEST_TEARDOWN_RETURN\"\n+else\n+\tip netns del \"$NS2\"\n+\treturned=$(wait_rdma_dev_on_netdev \"$DUMMY_B\")\n+\tktap_print_msg \"device returned to init_net as '${returned:-\u003cmissing\u003e}'\"\n+\tif rdma_dev_exists \"\" \"$RXE_SAME\" \u0026\u0026\n+\t [ -n \"$returned\" ] \u0026\u0026\n+\t [ \"$returned\" != \"$RXE_SAME\" ] \u0026\u0026\n+\t [ \"${returned#ibdev}\" != \"$returned\" ]; then\n+\t\tktap_test_pass \"$TEST_TEARDOWN_RETURN\"\n+\telse\n+\t\tktap_test_fail \"$TEST_TEARDOWN_RETURN\"\n+\tfi\n+fi\n+cleanup_devs\n+\n+ktap_finished\n"
} |
| 2/1 | 2026/07/10 03:55 | agent | patch-evaluator |
1mModel:gemini-3.1-pro-preview Args: null Results: {
"EnableConfigs": [
"INFINIBAND",
"CGROUP_RDMA",
"SMC",
"INFINIBAND_SRP",
"RDMA_RXE"
],
"FocusSymbols": [
"ib_device_set_netns_put",
"rdma_dev_change_netns",
"rdma_dev_pick_netns_name",
"nldev_set_doit",
"rdmacg_device_visible",
"smc_pnet_find_ib",
"srp_net_namespace",
"__alloc_name_id",
"rdma_dev_name_in_netns"
],
"Reasoning": "The patch introduces net namespace support for RDMA devices, allowing them to be isolated and renamed per network namespace. This involves functional changes to the RDMA core, RDMA cgroups, SMC, and SRP. These changes are reachable from userspace via netlink and cgroupfs, and thus should be fuzzed.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Do not list too generic configs (we already have them enabled). Only list those that specifically cover the modified code. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit 076ae9f7c55935fb1c38b8986d905d4eed559f6b
Author: syz-cluster <triage@syzkaller.com>
Date: Fri Jul 10 03:55:24 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/ABI/testing/configfs-rdma_cm b/Documentation/ABI/testing/configfs-rdma_cm
index 74f9506f42e7ac..739f7b6a12598b 100644
--- a/Documentation/ABI/testing/configfs-rdma_cm
+++ b/Documentation/ABI/testing/configfs-rdma_cm
@@ -12,6 +12,10 @@ Description: Interface is used to configure RDMA-cable HCAs in respect to
for this HCA has to be created:
mkdir -p /config/rdma_cm/<hca>
+ Note: configfs has no network namespace support, so this
+ interface cannot represent two devices that share a name in
+ different network namespaces (possible in exclusive netns mode).
+
What: /config/rdma_cm/<hca>/ports/<port-num>/default_roce_mode
Date: November 29, 2015
diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index 993446ab66d0fb..4523c1884d6715 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -2752,6 +2752,13 @@ RDMA
The "rdma" controller regulates the distribution and accounting of
RDMA resources.
+When RDMA devices are isolated per network namespace (exclusive mode),
+device names are unique only within a network namespace. The device lines
+below are therefore scoped to the reading or writing process's network
+namespace: only devices accessible from that namespace are listed, and a
+limit is applied to the device of that name in that namespace. Configure
+limits from the same network namespace as the workloads.
+
RDMA Interface Files
~~~~~~~~~~~~~~~~~~~~
diff --git a/drivers/infiniband/core/cgroup.c b/drivers/infiniband/core/cgroup.c
index 1f037fe01450ef..7a216ed45199bc 100644
--- a/drivers/infiniband/core/cgroup.c
+++ b/drivers/infiniband/core/cgroup.c
@@ -17,6 +17,8 @@
void ib_device_register_rdmacg(struct ib_device *device)
{
device->cg_device.name = device->name;
+ device->cg_device.netns_shared = ib_devices_shared_netns;
+ write_pnet(&device->cg_device.net, rdma_dev_net(device));
rdmacg_register_device(&device->cg_device);
}
@@ -34,6 +36,16 @@ void ib_device_unregister_rdmacg(struct ib_device *device)
rdmacg_unregister_device(&device->cg_device);
}
+void ib_device_rdmacg_change_netns(struct ib_device *device, struct net *net)
+{
+ write_pnet(&device->cg_device.net, net);
+}
+
+void ib_device_rdmacg_set_netns_shared(struct ib_device *device, bool shared)
+{
+ WRITE_ONCE(device->cg_device.netns_shared, shared);
+}
+
int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
struct ib_device *device,
enum rdmacg_resource_type resource_index)
diff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c
index 891e52afb8f4ba..c389d4e37b6bcf 100644
--- a/drivers/infiniband/core/cma_configfs.c
+++ b/drivers/infiniband/core/cma_configfs.c
@@ -65,6 +65,10 @@ static struct cma_dev_port_group *to_dev_port_group(struct config_item *item)
return container_of(group, struct cma_dev_port_group, group);
}
+/*
+ * configfs is not net namespace aware, so a name shared by devices in
+ * different namespaces resolves to the first match here.
+ */
static bool filter_by_name(struct ib_device *ib_dev, void *cookie)
{
return !strcmp(dev_name(&ib_dev->dev), cookie);
diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h
index 19104c542b270d..9cd671e2db2040 100644
--- a/drivers/infiniband/core/core_priv.h
+++ b/drivers/infiniband/core/core_priv.h
@@ -156,6 +156,8 @@ void ib_dispatch_event_clients(struct ib_event *event);
#ifdef CONFIG_CGROUP_RDMA
void ib_device_register_rdmacg(struct ib_device *device);
void ib_device_unregister_rdmacg(struct ib_device *device);
+void ib_device_rdmacg_change_netns(struct ib_device *device, struct net *net);
+void ib_device_rdmacg_set_netns_shared(struct ib_device *device, bool shared);
int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
struct ib_device *device,
@@ -173,6 +175,16 @@ static inline void ib_device_unregister_rdmacg(struct ib_device *device)
{
}
+static inline void ib_device_rdmacg_change_netns(struct ib_device *device,
+ struct net *net)
+{
+}
+
+static inline void ib_device_rdmacg_set_netns_shared(struct ib_device *device,
+ bool shared)
+{
+}
+
static inline int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
struct ib_device *device,
enum rdmacg_resource_type resource_index)
@@ -356,7 +368,8 @@ void ib_port_unregister_client_groups(struct ib_device *ibdev, u32 port_num,
const struct attribute_group **groups);
int ib_device_set_netns_put(struct sk_buff *skb,
- struct ib_device *dev, u32 ns_fd);
+ struct ib_device *dev, u32 ns_fd, const char *name,
+ struct netlink_ext_ack *extack);
int rdma_nl_net_init(struct rdma_dev_net *rnet);
void rdma_nl_net_exit(struct rdma_dev_net *rnet);
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index b8193e077a746f..cffb0de1c0016b 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -129,7 +129,7 @@ static DECLARE_RWSEM(rdma_nets_rwsem);
bool ib_devices_shared_netns = true;
module_param_named(netns_mode, ib_devices_shared_netns, bool, 0444);
MODULE_PARM_DESC(netns_mode,
- "Share device among net namespaces; default=1 (shared)");
+ "Share device among net namespaces; default=1 (shared). In exclusive mode device names are unique per net namespace");
/**
* rdma_dev_access_netns() - Return whether an rdma device can be accessed
* from a specified net namespace or not.
@@ -268,7 +268,8 @@ static struct notifier_block ibdev_lsm_nb = {
};
static int rdma_dev_change_netns(struct ib_device *device, struct net *cur_net,
- struct net *net);
+ struct net *net, const char *requested_name,
+ const char *fallback_pattern);
/* Pointer to the RCU head at the start of the ib_port_data array */
struct ib_port_data_rcu {
@@ -351,13 +352,15 @@ void ib_device_put(struct ib_device *device)
}
EXPORT_SYMBOL(ib_device_put);
-static struct ib_device *__ib_device_get_by_name(const char *name)
+static struct ib_device *__ib_device_get_by_name(const char *name,
+ const struct net *net)
{
struct ib_device *device;
unsigned long index;
xa_for_each (&devices, index, device)
- if (!strcmp(name, dev_name(&device->dev)))
+ if (rdma_dev_access_netns(device, net) &&
+ !strcmp(name, dev_name(&device->dev)))
return device;
return NULL;
@@ -395,7 +398,7 @@ int ib_device_rename(struct ib_device *ibdev, const char *name)
return 0;
}
- if (__ib_device_get_by_name(name)) {
+ if (__ib_device_get_by_name(name, rdma_dev_net(ibdev))) {
up_write(&devices_rwsem);
return -EEXIST;
}
@@ -435,7 +438,13 @@ int ib_device_set_dim(struct ib_device *ibdev, u8 use_dim)
return 0;
}
-static int alloc_name(struct ib_device *ibdev, const char *name)
+/*
+ * Pick a free index for the '%d' style @name pattern within net namespace
+ * @net. Returns the index on success or a negative errno. The caller builds
+ * the final unique device name from the returned index.
+ */
+static int __alloc_name_id(struct net *net, const char *name,
+ const struct ib_device *skip)
{
struct ib_device *device;
unsigned long index;
@@ -448,6 +457,8 @@ static int alloc_name(struct ib_device *ibdev, const char *name)
xa_for_each (&devices, index, device) {
char buf[IB_DEVICE_NAME_MAX];
+ if (device == skip || !rdma_dev_access_netns(device, net))
+ continue;
if (sscanf(dev_name(&device->dev), name, &i) != 1)
continue;
if (i < 0 || i >= INT_MAX)
@@ -462,15 +473,27 @@ static int alloc_name(struct ib_device *ibdev, const char *name)
}
rc = ida_alloc(&inuse, GFP_KERNEL);
- if (rc < 0)
- goto out;
-
- rc = dev_set_name(&ibdev->dev, name, rc);
out:
ida_destroy(&inuse);
return rc;
}
+static int alloc_name_id(struct net *net, const char *name)
+{
+ return __alloc_name_id(net, name, NULL);
+}
+
+static int alloc_name(struct ib_device *ibdev, const char *name)
+{
+ int id;
+
+ id = alloc_name_id(rdma_dev_net(ibdev), name);
+ if (id < 0)
+ return id;
+
+ return dev_set_name(&ibdev->dev, name, id);
+}
+
static void ib_device_release(struct device *device)
{
struct ib_device *dev = container_of(device, struct ib_device, dev);
@@ -1094,6 +1117,7 @@ static int add_all_compat_devs(void)
int rdma_compatdev_set(u8 enable)
{
struct rdma_dev_net *rnet;
+ struct ib_device *dev;
unsigned long index;
int ret = 0;
@@ -1116,6 +1140,12 @@ int rdma_compatdev_set(u8 enable)
if (ret)
return -EBUSY;
+ /* Keep each registered device's rdma cgroup visibility in sync. */
+ down_read(&devices_rwsem);
+ xa_for_each_marked(&devices, index, dev, DEVICE_REGISTERED)
+ ib_device_rdmacg_set_netns_shared(dev, enable);
+ up_read(&devices_rwsem);
+
if (enable)
ret = add_all_compat_devs();
else
@@ -1151,8 +1181,17 @@ static void rdma_dev_exit_net(struct net *net)
/*
* If the real device is in the NS then move it back to init.
+ * Provide a fallback pattern so a name conflict in init_net
+ * cannot make the teardown move fail.
*/
- rdma_dev_change_netns(dev, net, &init_net);
+ if (net_eq(net, read_pnet(&dev->coredev.rdma_net))) {
+ ret = rdma_dev_change_netns(dev, net, &init_net,
+ NULL, "ibdev%d");
+ if (ret)
+ WARN(1,
+ "Failed to move RDMA device %s to init_net on netns exit: %d\n",
+ dev_name(&dev->dev), ret);
+ }
put_device(&dev->dev);
down_read(&devices_rwsem);
@@ -1206,7 +1245,8 @@ static __net_init int rdma_dev_init_net(struct net *net)
}
/*
- * Assign the unique string device name and the unique device index. This is
+ * Assign the unique string device name and the unique device index. The device
+ * name is unique within the net namespace the device is assigned to. This is
* undone by ib_dealloc_device.
*/
static int assign_name(struct ib_device *device, const char *name)
@@ -1223,7 +1263,8 @@ static int assign_name(struct ib_device *device, const char *name)
if (ret)
goto out;
- if (__ib_device_get_by_name(dev_name(&device->dev))) {
+ if (__ib_device_get_by_name(dev_name(&device->dev),
+ rdma_dev_net(device))) {
ret = -ENFILE;
goto out;
}
@@ -1322,6 +1363,7 @@ static int enable_device_and_get(struct ib_device *device)
*/
refcount_set(&device->refcount, 2);
down_write(&devices_rwsem);
+ ib_device_rdmacg_set_netns_shared(device, ib_devices_shared_netns);
xa_set_mark(&devices, device->index, DEVICE_REGISTERED);
/*
@@ -1388,8 +1430,9 @@ static void ib_device_notify_register(struct ib_device *device)
/**
* ib_register_device - Register an IB device with IB core
* @device: Device to register
- * @name: unique string device name. This may include a '%' which will
- * cause a unique index to be added to the passed device name.
+ * @name: device name, unique within the device's net namespace. This may
+ * include a '%' which will cause a unique index to be added to the
+ * passed device name.
* @dma_device: pointer to a DMA-capable device. If %NULL, then the IB
* device will be used. In this case the caller should fully
* setup the ibdev for DMA. This usually means using dma_virt_ops.
@@ -1670,14 +1713,83 @@ void ib_unregister_device_queued(struct ib_device *ib_dev)
}
EXPORT_SYMBOL(ib_unregister_device_queued);
+static bool rdma_dev_name_in_netns(struct ib_device *skip, struct net *net,
+ const char *name)
+{
+ struct ib_device *device;
+ unsigned long index;
+
+ lockdep_assert_held_write(&devices_rwsem);
+
+ xa_for_each(&devices, index, device)
+ if (device != skip &&
+ rdma_dev_access_netns(device, net) &&
+ !strcmp(name, dev_name(&device->dev)))
+ return true;
+
+ return false;
+}
+
+/*
+ * Choose the name @device should use in net namespace @net. @requested_name
+ * is used as a literal device name when set. Otherwise keep the current name
+ * when it is free, or use a trusted '%d' @fallback_pattern for teardown. The
+ * caller must hold the write side of devices_rwsem.
+ */
+static int rdma_dev_pick_netns_name(struct ib_device *device, struct net *net,
+ const char *requested_name,
+ const char *fallback_pattern,
+ char *buf, size_t buf_len,
+ const char **new_name)
+{
+ int id;
+
+ lockdep_assert_held_write(&devices_rwsem);
+
+ if (requested_name) {
+ if (!rdma_dev_name_in_netns(device, net, requested_name)) {
+ *new_name = requested_name;
+ return 0;
+ }
+
+ return -EEXIST;
+ }
+
+ if (!rdma_dev_name_in_netns(device, net, dev_name(&device->dev))) {
+ *new_name = dev_name(&device->dev);
+ return 0;
+ }
+
+ if (!fallback_pattern)
+ return -EEXIST;
+
+ snprintf(buf, buf_len, "ibdev%u", device->index);
+ if (!rdma_dev_name_in_netns(device, net, buf)) {
+ *new_name = buf;
+ return 0;
+ }
+
+ id = __alloc_name_id(net, fallback_pattern, device);
+ if (id < 0)
+ return id;
+ snprintf(buf, buf_len, fallback_pattern, id);
+ *new_name = buf;
+ return 0;
+}
+
/*
* The caller must pass in a device that has the kref held and the refcount
* released. If the device is in cur_net and still registered then it is moved
* into net.
+ *
+ * Naming rules are handled by rdma_dev_pick_netns_name().
*/
static int rdma_dev_change_netns(struct ib_device *device, struct net *cur_net,
- struct net *net)
+ struct net *net, const char *requested_name,
+ const char *fallback_pattern)
{
+ char buf[IB_DEVICE_NAME_MAX];
+ const char *new_name;
int ret2 = -EINVAL;
int ret;
@@ -1694,30 +1806,68 @@ static int rdma_dev_change_netns(struct ib_device *device, struct net *cur_net,
goto out;
}
+ if (!fallback_pattern) {
+ /*
+ * Reject a predictable name conflict before tearing anything
+ * down, so a doomed user move does not disable a live device.
+ */
+ down_write(&devices_rwsem);
+ ret = rdma_dev_pick_netns_name(device, net, requested_name,
+ fallback_pattern, buf,
+ sizeof(buf), &new_name);
+ up_write(&devices_rwsem);
+ if (ret)
+ goto out;
+ }
+
kobject_uevent(&device->dev.kobj, KOBJ_REMOVE);
disable_device(device);
/*
- * At this point no one can be using the device, so it is safe to
- * change the namespace.
+ * Recompute the destination name under the write side of devices_rwsem
+ * now that the device is disabled, closing races with a concurrent
+ * registration or rename, then publish the new namespace at the sysfs
+ * level.
*/
- write_pnet(&device->coredev.rdma_net, net);
+ down_write(&devices_rwsem);
+ ret = rdma_dev_pick_netns_name(device, net, requested_name,
+ fallback_pattern, buf, sizeof(buf),
+ &new_name);
+ if (ret) {
+ if (fallback_pattern) {
+ WARN(1,
+ "%s: failed to pick device name during namespace teardown: %d\n",
+ __func__, ret);
+ write_pnet(&device->coredev.rdma_net, net);
+ ib_device_rdmacg_change_netns(device, net);
+ ret = 0;
+ }
+ goto rename_done;
+ }
- down_read(&devices_rwsem);
- /*
- * Currently rdma devices are system wide unique. So the device name
- * is guaranteed free in the new namespace. Publish the new namespace
- * at the sysfs level.
- */
- ret = device_rename(&device->dev, dev_name(&device->dev));
- up_read(&devices_rwsem);
+ write_pnet(&device->coredev.rdma_net, net);
+ ib_device_rdmacg_change_netns(device, net);
+ ret = device_rename(&device->dev, new_name);
if (ret) {
- dev_warn(&device->dev,
- "%s: Couldn't rename device after namespace change\n",
- __func__);
- /* Try and put things back and re-enable the device */
- write_pnet(&device->coredev.rdma_net, cur_net);
+ if (fallback_pattern) {
+ WARN(1,
+ "%s: failed to rename device during namespace teardown: %d\n",
+ __func__, ret);
+ ret = 0;
+ } else {
+ dev_warn(&device->dev,
+ "%s: Couldn't rename device after namespace change\n",
+ __func__);
+ /* Try and put things back and re-enable the device */
+ write_pnet(&device->coredev.rdma_net, cur_net);
+ ib_device_rdmacg_change_netns(device, cur_net);
+ }
+ } else {
+ strscpy(device->name, dev_name(&device->dev),
+ IB_DEVICE_NAME_MAX);
}
+rename_done:
+ up_write(&devices_rwsem);
ret2 = enable_device_and_get(device);
if (ret2) {
@@ -1740,36 +1890,72 @@ static int rdma_dev_change_netns(struct ib_device *device, struct net *cur_net,
}
int ib_device_set_netns_put(struct sk_buff *skb,
- struct ib_device *dev, u32 ns_fd)
+ struct ib_device *dev, u32 ns_fd, const char *name,
+ struct netlink_ext_ack *extack)
{
struct net *net;
int ret;
net = get_net_ns_by_fd(ns_fd);
if (IS_ERR(net)) {
+ NL_SET_ERR_MSG(extack, "Invalid target net namespace fd");
ret = PTR_ERR(net);
goto net_err;
}
if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
+ NL_SET_ERR_MSG(extack,
+ "Missing CAP_NET_ADMIN in the target net namespace");
ret = -EPERM;
goto ns_err;
}
+ /*
+ * Moving a device to the namespace it already lives in is a no-op; a
+ * supplied name still renames it in place.
+ */
+ if (net_eq(net, read_pnet(&dev->coredev.rdma_net))) {
+ ret = name ? ib_device_rename(dev, name) : 0;
+
+ if (ret == -EEXIST)
+ NL_SET_ERR_MSG(extack,
+ "Device name already exists in the target net namespace");
+ else if (ret == -EINVAL && name)
+ NL_SET_ERR_MSG(extack,
+ "Unable to use requested device name in the target net namespace");
+ goto ns_err;
+ }
+
/*
* All the ib_clients, including uverbs, are reset when the namespace is
* changed and this cannot be blocked waiting for userspace to do
* something, so disassociation is mandatory.
*/
- if (!dev->ops.disassociate_ucontext || ib_devices_shared_netns) {
+ if (ib_devices_shared_netns) {
+ NL_SET_ERR_MSG(extack,
+ "Cannot change net namespace of RDMA device in shared netns mode");
+ ret = -EOPNOTSUPP;
+ goto ns_err;
+ }
+
+ if (!dev->ops.disassociate_ucontext) {
+ NL_SET_ERR_MSG(extack,
+ "Device does not support namespace changes (no disassociate support)");
ret = -EOPNOTSUPP;
goto ns_err;
}
get_device(&dev->dev);
ib_device_put(dev);
- ret = rdma_dev_change_netns(dev, current->nsproxy->net_ns, net);
+ ret = rdma_dev_change_netns(dev, current->nsproxy->net_ns, net, name,
+ NULL);
put_device(&dev->dev);
+ if (ret == -EEXIST)
+ NL_SET_ERR_MSG(extack,
+ "Device name already exists in the target net namespace");
+ else if (ret == -EINVAL && name)
+ NL_SET_ERR_MSG(extack,
+ "Unable to use requested device name in the target net namespace");
put_net(net);
return ret;
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index f599c24b34e81b..473bf9667f83e6 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -1177,6 +1177,24 @@ static int nldev_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
if (!device)
return -EINVAL;
+ if (tb[RDMA_NLDEV_NET_NS_FD]) {
+ char name[IB_DEVICE_NAME_MAX] = {};
+ u32 ns_fd;
+
+ if (tb[RDMA_NLDEV_ATTR_DEV_NAME]) {
+ nla_strscpy(name, tb[RDMA_NLDEV_ATTR_DEV_NAME],
+ IB_DEVICE_NAME_MAX);
+ if (strlen(name) == 0) {
+ err = -EINVAL;
+ goto done;
+ }
+ }
+ ns_fd = nla_get_u32(tb[RDMA_NLDEV_NET_NS_FD]);
+ err = ib_device_set_netns_put(skb, device, ns_fd,
+ name[0] ? name : NULL, extack);
+ goto put_done;
+ }
+
if (tb[RDMA_NLDEV_ATTR_DEV_NAME]) {
char name[IB_DEVICE_NAME_MAX] = {};
@@ -1190,14 +1208,6 @@ static int nldev_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
goto done;
}
- if (tb[RDMA_NLDEV_NET_NS_FD]) {
- u32 ns_fd;
-
- ns_fd = nla_get_u32(tb[RDMA_NLDEV_NET_NS_FD]);
- err = ib_device_set_netns_put(skb, device, ns_fd);
- goto put_done;
- }
-
if (tb[RDMA_NLDEV_ATTR_DEV_DIM]) {
u8 use_dim;
diff --git a/drivers/infiniband/core/security.c b/drivers/infiniband/core/security.c
index 9af31d1d9d70c7..a82c46965416a1 100644
--- a/drivers/infiniband/core/security.c
+++ b/drivers/infiniband/core/security.c
@@ -700,6 +700,12 @@ int ib_mad_agent_security_setup(struct ib_mad_agent *agent,
if (qp_type != IB_QPT_SMI)
return 0;
+ /*
+ * SELinux labels an endport by (device name, port) from a global
+ * policy. If devices in different net namespaces share a name, they get
+ * the same label; distinguishing them would need net namespace support
+ * in the policy language and tooling.
+ */
spin_lock(&mad_agent_list_lock);
ret = security_ib_endport_manage_subnet(agent->security,
dev_name(&agent->device->dev),
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 1ec130fee8ea7a..6eb10d2f0653bc 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -240,6 +240,10 @@ static void rxe_dealloc_ucontext(struct ib_ucontext *ibuc)
rxe_err_uc(uc, "cleanup failed, err = %d\n", err);
}
+static void rxe_disassociate_ucontext(struct ib_ucontext *ibuc)
+{
+}
+
/* pd */
static int rxe_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
{
@@ -1478,6 +1482,7 @@ static const struct ib_device_ops rxe_dev_ops = {
.destroy_srq = rxe_destroy_srq,
.detach_mcast = rxe_detach_mcast,
.device_group = &rxe_attr_group,
+ .disassociate_ucontext = rxe_disassociate_ucontext,
.enable_driver = rxe_enable_driver,
.get_dma_mr = rxe_get_dma_mr,
.get_hw_stats = rxe_ib_get_hw_stats,
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index acbd787de265b5..a070fcf86e8a66 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -3189,10 +3189,24 @@ static struct attribute *srp_class_attrs[];
ATTRIBUTE_GROUPS(srp_class);
+/*
+ * SRP hosts are named after their ib device, so tag the class by the ib
+ * device's net namespace.
+ */
+static const struct ns_common *srp_net_namespace(const struct device *dev)
+{
+ struct srp_host *host = container_of(dev, struct srp_host, dev);
+ struct net *net = rdma_dev_net(host->srp_dev->dev);
+
+ return net ? to_ns_common(net) : NULL;
+}
+
static struct class srp_class = {
.name = "infiniband_srp",
.dev_groups = srp_class_groups,
- .dev_release = srp_release_dev
+ .dev_release = srp_release_dev,
+ .ns_type = &net_ns_type_operations,
+ .namespace = srp_net_namespace,
};
/**
diff --git a/include/linux/cgroup_rdma.h b/include/linux/cgroup_rdma.h
index 404e746552ca8f..71170cb0e19e34 100644
--- a/include/linux/cgroup_rdma.h
+++ b/include/linux/cgroup_rdma.h
@@ -7,6 +7,7 @@
#define _CGROUP_RDMA_H
#include <linux/cgroup.h>
+#include <net/net_namespace.h>
enum rdmacg_resource_type {
RDMACG_RESOURCE_HCA_HANDLE,
@@ -34,6 +35,15 @@ struct rdmacg_device {
struct list_head dev_node;
struct list_head rpools;
char *name;
+ /*
+ * Net namespace the device belongs to. @netns_shared mirrors
+ * ib_devices_shared_netns: when true the device is visible from every
+ * net namespace (shared mode); otherwise @net is the only namespace
+ * that may see and configure it. @netns_shared is updated when the
+ * sharing mode changes, so use {READ,WRITE}_ONCE() to access it.
+ */
+ possible_net_t net;
+ bool netns_shared;
};
/*
diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h
index 3af946ecbac3ed..ee11c3bbbae22a 100644
--- a/include/uapi/rdma/rdma_netlink.h
+++ b/include/uapi/rdma/rdma_netlink.h
@@ -516,7 +516,10 @@ enum rdma_nldev_attr {
RDMA_NLDEV_ATTR_DEV_PROTOCOL, /* string */
/*
- * File descriptor handle of the net namespace object
+ * File descriptor handle of the net namespace object. May be combined
+ * with RDMA_NLDEV_ATTR_DEV_NAME (a literal device name) to also rename
+ * the device in the destination namespace; the move fails with -EEXIST
+ * if that name is already taken there.
*/
RDMA_NLDEV_NET_NS_FD, /* u32 */
/*
diff --git a/kernel/cgroup/rdma.c b/kernel/cgroup/rdma.c
index 5e82a03b3270ad..c8b4e3de763051 100644
--- a/kernel/cgroup/rdma.c
+++ b/kernel/cgroup/rdma.c
@@ -15,6 +15,7 @@
#include <linux/cgroup.h>
#include <linux/parser.h>
#include <linux/cgroup_rdma.h>
+#include <linux/nsproxy.h>
#define RDMACG_MAX_STR "max"
@@ -464,6 +465,13 @@ void rdmacg_unregister_device(struct rdmacg_device *device)
}
EXPORT_SYMBOL(rdmacg_unregister_device);
+/* netns_shared is toggled without rdmacg_mutex, hence READ_ONCE(). */
+static bool rdmacg_device_visible(const struct rdmacg_device *device)
+{
+ return READ_ONCE(device->netns_shared) ||
+ net_eq(read_pnet(&device->net), current->nsproxy->net_ns);
+}
+
static struct rdmacg_device *rdmacg_get_device_locked(const char *name)
{
struct rdmacg_device *device;
@@ -471,7 +479,8 @@ static struct rdmacg_device *rdmacg_get_device_locked(const char *name)
lockdep_assert_held(&rdmacg_mutex);
list_for_each_entry(device, &rdmacg_devices, dev_node)
- if (!strcmp(name, device->name))
+ if (rdmacg_device_visible(device) &&
+ !strcmp(name, device->name))
return device;
return NULL;
@@ -626,6 +635,9 @@ static int rdmacg_resource_read(struct seq_file *sf, void *v)
mutex_lock(&rdmacg_mutex);
list_for_each_entry(device, &rdmacg_devices, dev_node) {
+ if (!rdmacg_device_visible(device))
+ continue;
+
seq_printf(sf, "%s ", device->name);
rpool = find_cg_rpool_locked(cg, device);
@@ -648,6 +660,9 @@ static int rdmacg_events_show(struct seq_file *sf, void *v)
mutex_lock(&rdmacg_mutex);
list_for_each_entry(device, &rdmacg_devices, dev_node) {
+ if (!rdmacg_device_visible(device))
+ continue;
+
rpool = find_cg_rpool_locked(cg, device);
seq_printf(sf, "%s ", device->name);
@@ -677,6 +692,9 @@ static int rdmacg_events_local_show(struct seq_file *sf, void *v)
mutex_lock(&rdmacg_mutex);
list_for_each_entry(device, &rdmacg_devices, dev_node) {
+ if (!rdmacg_device_visible(device))
+ continue;
+
rpool = find_cg_rpool_locked(cg, device);
seq_printf(sf, "%s ", device->name);
diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c
index 63e286e2dfaa8d..ff9c9c35cc2f5b 100644
--- a/net/smc/smc_pnet.c
+++ b/net/smc/smc_pnet.c
@@ -304,13 +304,18 @@ static bool smc_pnetid_valid(const char *pnet_name, char *pnetid)
return true;
}
-/* Find an infiniband device by a given name. The device might not exist. */
-static struct smc_ib_device *smc_pnet_find_ib(char *ib_name)
+/*
+ * Find an infiniband device by a given name, restricted to the devices
+ * accessible from @net. The device might not exist.
+ */
+static struct smc_ib_device *smc_pnet_find_ib(struct net *net, char *ib_name)
{
struct smc_ib_device *ibdev;
mutex_lock(&smc_ib_devices.mutex);
list_for_each_entry(ibdev, &smc_ib_devices.list, list) {
+ if (!rdma_dev_access_netns(ibdev->ibdev, net))
+ continue;
if (!strncmp(ibdev->ibdev->name, ib_name,
sizeof(ibdev->ibdev->name)) ||
(ibdev->ibdev->dev.parent &&
@@ -408,8 +413,8 @@ static int smc_pnet_add_eth(struct smc_pnettable *pnettable, struct net *net,
return rc;
}
-static int smc_pnet_add_ib(struct smc_pnettable *pnettable, char *ib_name,
- u8 ib_port, char *pnet_name)
+static int smc_pnet_add_ib(struct smc_pnettable *pnettable, struct net *net,
+ char *ib_name, u8 ib_port, char *pnet_name)
{
struct smc_pnetentry *tmp_pe, *new_pe;
struct smc_ib_device *ib_dev;
@@ -419,7 +424,7 @@ static int smc_pnet_add_ib(struct smc_pnettable *pnettable, char *ib_name,
bool new_ibdev;
/* try to apply the pnetid to active devices */
- ib_dev = smc_pnet_find_ib(ib_name);
+ ib_dev = smc_pnet_find_ib(net, ib_name);
if (ib_dev) {
ibdev_applied = smc_pnet_apply_ib(ib_dev, ib_port, pnet_name);
if (ibdev_applied)
@@ -518,7 +523,7 @@ static int smc_pnet_enter(struct net *net, struct nlattr *tb[])
if (ibport < 1 || ibport > SMC_MAX_PORTS)
goto error;
}
- rc = smc_pnet_add_ib(pnettable, string, ibport, pnet_name);
+ rc = smc_pnet_add_ib(pnettable, net, string, ibport, pnet_name);
if (!rc)
new_ibdev = true;
else if (rc != -EEXIST)
@@ -1170,6 +1175,9 @@ int smc_pnetid_by_table_ib(struct smc_ib_device *smcibdev, u8 ib_port)
struct smc_net *sn;
int rc = -ENOENT;
+ if (!rdma_dev_access_netns(smcibdev->ibdev, &init_net))
+ return -ENOENT;
+
/* get pnettable for init namespace */
sn = net_generic(&init_net, smc_net_id);
pnettable = &sn->pnettable;
diff --git a/tools/testing/selftests/rdma/Makefile b/tools/testing/selftests/rdma/Makefile
index 07af7f15c1bf74..a91c14c45006e3 100644
--- a/tools/testing/selftests/rdma/Makefile
+++ b/tools/testing/selftests/rdma/Makefile
@@ -3,6 +3,7 @@ TEST_PROGS := rxe_rping_between_netns.sh \
rxe_ipv6.sh \
rxe_socket_with_netns.sh \
rxe_test_NETDEV_UNREGISTER.sh \
- rxe_sent_rcvd_bytes.sh
+ rxe_sent_rcvd_bytes.sh \
+ rxe_netns_names.sh
include ../lib.mk
diff --git a/tools/testing/selftests/rdma/config b/tools/testing/selftests/rdma/config
index 4ffb814e253bbd..e1ff54ec0f5790 100644
--- a/tools/testing/selftests/rdma/config
+++ b/tools/testing/selftests/rdma/config
@@ -1,3 +1,5 @@
CONFIG_TUN
CONFIG_VETH
+CONFIG_DUMMY
+CONFIG_NET_NS
CONFIG_RDMA_RXE
diff --git a/tools/testing/selftests/rdma/rxe_netns_names.sh b/tools/testing/selftests/rdma/rxe_netns_names.sh
new file mode 100755
index 00000000000000..a7e57706fdff75
--- /dev/null
+++ b/tools/testing/selftests/rdma/rxe_netns_names.sh
@@ -0,0 +1,282 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Exercise RDMA device name handling across network namespaces.
+
+source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
+
+NAME_PREFIX="rxe_netns_names_$$"
+NETDEV_PREFIX="rxn$$"
+NS1="${NAME_PREFIX}ns1"
+NS2="${NAME_PREFIX}ns2"
+RXE_A="${NAME_PREFIX}rxe_a"
+RXE_B="${NAME_PREFIX}rxe_b"
+RXE_SAME="${NAME_PREFIX}rxe_same"
+RXE_NEW="${NAME_PREFIX}rxe_new"
+DUMMY_A="${NETDEV_PREFIX}a"
+DUMMY_B="${NETDEV_PREFIX}b"
+OLD_MODE=""
+MODE_CHANGED=0
+MODS=("dummy" "rdma_rxe")
+TEST_SAME_NAMES="same RDMA device name can exist in two net namespaces"
+TEST_MOVE_CONFLICT="move without rename fails on destination name conflict"
+TEST_MOVE_RENAME="move then rename succeeds"
+TEST_COMBINED_MOVE_RENAME="move with requested destination name succeeds"
+TEST_SAME_NETNS_DUP_RENAME="same-netns rename rejects duplicate name"
+TEST_TEARDOWN_RETURN="netns delete returns device to init_net and renames on conflict"
+
+ksft_skip()
+{
+ ktap_skip_all "$*"
+ exit "$KSFT_SKIP"
+}
+
+fail()
+{
+ ktap_exit_fail_msg "$*"
+}
+
+need_cmd()
+{
+ command -v "$1" >/dev/null 2>&1 || ksft_skip "missing command: $1"
+}
+
+rdma_ns()
+{
+ local ns=$1
+
+ shift
+ ip netns exec "$ns" rdma "$@"
+}
+
+rdma_dev_exists()
+{
+ local ns=$1
+ local dev=$2
+
+ if [ -n "$ns" ]; then
+ rdma_ns "$ns" dev show "$dev" >/dev/null 2>&1
+ else
+ rdma dev show "$dev" >/dev/null 2>&1
+ fi
+}
+
+add_dummy()
+{
+ local netdev=$1
+
+ ip link add "$netdev" type dummy || return 1
+ ip link set "$netdev" up || return 1
+}
+
+add_rxe()
+{
+ local dev=$1
+ local netdev=$2
+
+ rdma link add "$dev" type rxe netdev "$netdev"
+}
+
+rdma_dev_on_netdev()
+{
+ local netdev=$1
+
+ rdma link show 2>/dev/null | awk -v want="$netdev" '
+ {
+ for (i = 1; i < NF; i++)
+ if ($i == "netdev" && $(i + 1) == want) {
+ dev = $2
+ sub(/\/.*/, "", dev)
+ print dev
+ exit
+ }
+ }'
+}
+
+wait_rdma_dev_on_netdev()
+{
+ local netdev=$1
+ local dev
+ local i
+
+ for i in $(seq 1 50); do
+ dev=$(rdma_dev_on_netdev "$netdev")
+ if [ -n "$dev" ]; then
+ echo "$dev"
+ return 0
+ fi
+ sleep 0.1
+ done
+
+ return 1
+}
+
+setup_devs()
+{
+ cleanup_devs
+
+ add_dummy "$DUMMY_A" || return 1
+ add_dummy "$DUMMY_B" || return 1
+
+ add_rxe "$RXE_A" "$DUMMY_A" || return 1
+ add_rxe "$RXE_B" "$DUMMY_B" || return 1
+}
+
+cleanup_devs()
+{
+ ip link del "$DUMMY_A" 2>/dev/null
+ ip link del "$DUMMY_B" 2>/dev/null
+}
+
+setup()
+{
+ OLD_MODE=$(rdma system show 2>/dev/null |
+ sed -n 's/.*netns \([^ ]*\).*/\1/p')
+ [ -n "$OLD_MODE" ] || ksft_skip "failed to read RDMA netns mode"
+
+ rdma system set netns exclusive >/dev/null 2>&1 ||
+ ksft_skip "rdma netns exclusive mode is not supported"
+ MODE_CHANGED=1
+
+ ip netns add "$NS1" || return 1
+ ip netns add "$NS2" || return 1
+}
+
+cleanup()
+{
+ cleanup_devs
+
+ ip netns del "$NS1" 2>/dev/null
+ ip netns del "$NS2" 2>/dev/null
+
+ if [ "$MODE_CHANGED" -eq 1 ]; then
+ rdma system set netns "$OLD_MODE" 2>/dev/null
+ fi
+
+ for m in "${MODS[@]}"; do
+ modprobe -r "$m" 2>/dev/null
+ done
+}
+
+rdma_supports_combined_move_rename()
+{
+ rdma dev help 2>&1 | grep -Eq 'netns .*name|name .*netns'
+}
+
+[ "$(id -u)" -eq 0 ] || ksft_skip "must be run as root"
+need_cmd ip
+need_cmd rdma
+need_cmd modprobe
+
+trap cleanup EXIT
+
+for m in "${MODS[@]}"; do
+ modinfo "$m" >/dev/null 2>&1 || ksft_skip "module $m not found"
+ modprobe "$m" || fail "failed to load $m"
+done
+
+setup || fail "failed to create net namespaces"
+
+ktap_print_header
+ktap_set_plan 7
+
+if setup_devs &&
+ rdma dev set "$RXE_A" netns "$NS1" &&
+ rdma_ns "$NS1" dev set "$RXE_A" name "$RXE_SAME" &&
+ rdma dev set "$RXE_B" netns "$NS2" &&
+ rdma_ns "$NS2" dev set "$RXE_B" name "$RXE_SAME" &&
+ rdma_dev_exists "$NS1" "$RXE_SAME" &&
+ rdma_dev_exists "$NS2" "$RXE_SAME"; then
+ ktap_test_pass "$TEST_SAME_NAMES"
+else
+ ktap_test_fail "$TEST_SAME_NAMES"
+fi
+cleanup_devs
+
+if ! setup_devs ||
+ ! rdma dev set "$RXE_A" netns "$NS1" ||
+ ! rdma_ns "$NS1" dev set "$RXE_A" name "$RXE_SAME" ||
+ ! rdma dev set "$RXE_B" netns "$NS2" ||
+ ! rdma_ns "$NS2" dev set "$RXE_B" name "$RXE_SAME"; then
+ ktap_test_fail "$TEST_MOVE_CONFLICT"
+elif rdma_ns "$NS1" dev set "$RXE_SAME" netns "$NS2" >/dev/null 2>&1; then
+ ktap_test_fail "$TEST_MOVE_CONFLICT"
+elif rdma_dev_exists "$NS1" "$RXE_SAME" &&
+ rdma_dev_exists "$NS2" "$RXE_SAME"; then
+ ktap_test_pass "$TEST_MOVE_CONFLICT"
+else
+ ktap_test_fail "$TEST_MOVE_CONFLICT"
+fi
+cleanup_devs
+
+if ! setup_devs; then
+ ktap_test_fail "$TEST_MOVE_RENAME"
+elif rdma dev set "$RXE_A" netns "$NS2" &&
+ rdma_ns "$NS2" dev set "$RXE_A" name "$RXE_NEW"; then
+ if rdma_dev_exists "$NS2" "$RXE_NEW" &&
+ ! rdma_dev_exists "" "$RXE_A"; then
+ ktap_test_pass "$TEST_MOVE_RENAME"
+ else
+ ktap_test_fail "$TEST_MOVE_RENAME"
+ fi
+else
+ ktap_test_fail "$TEST_MOVE_RENAME"
+fi
+cleanup_devs
+
+if ! rdma_supports_combined_move_rename; then
+ ktap_test_skip "$TEST_COMBINED_MOVE_RENAME"
+elif ! setup_devs; then
+ ktap_test_fail "$TEST_COMBINED_MOVE_RENAME"
+elif rdma dev set "$RXE_A" netns "$NS2" name "$RXE_NEW"; then
+ if rdma_dev_exists "$NS2" "$RXE_NEW" &&
+ ! rdma_dev_exists "" "$RXE_A"; then
+ ktap_test_pass "$TEST_COMBINED_MOVE_RENAME"
+ else
+ ktap_test_fail "$TEST_COMBINED_MOVE_RENAME"
+ fi
+else
+ ktap_test_fail "$TEST_COMBINED_MOVE_RENAME"
+fi
+cleanup_devs
+
+if ! setup_devs; then
+ ktap_test_fail "$TEST_SAME_NETNS_DUP_RENAME"
+elif rdma dev set "$RXE_A" name "$RXE_SAME" &&
+ rdma dev set "$RXE_B" name "$RXE_NEW"; then
+ if rdma dev set "$RXE_A" name "$RXE_NEW" >/dev/null 2>&1; then
+ ktap_test_fail "$TEST_SAME_NETNS_DUP_RENAME"
+ elif rdma_dev_exists "" "$RXE_SAME" &&
+ rdma_dev_exists "" "$RXE_NEW"; then
+ ktap_test_pass "$TEST_SAME_NETNS_DUP_RENAME"
+ else
+ ktap_test_fail "$TEST_SAME_NETNS_DUP_RENAME"
+ fi
+else
+ ktap_test_fail "$TEST_SAME_NETNS_DUP_RENAME"
+fi
+cleanup_devs
+
+if ! setup_devs; then
+ ktap_test_fail "$TEST_TEARDOWN_RETURN"
+elif ! rdma dev set "$RXE_A" name "$RXE_SAME" ||
+ ! rdma dev set "$RXE_B" netns "$NS2" ||
+ ! rdma_ns "$NS2" dev set "$RXE_B" name "$RXE_SAME" ||
+ ! rdma_dev_exists "$NS2" "$RXE_SAME"; then
+ ktap_test_fail "$TEST_TEARDOWN_RETURN"
+else
+ ip netns del "$NS2"
+ returned=$(wait_rdma_dev_on_netdev "$DUMMY_B")
+ ktap_print_msg "device returned to init_net as '${returned:-<missing>}'"
+ if rdma_dev_exists "" "$RXE_SAME" &&
+ [ -n "$returned" ] &&
+ [ "$returned" != "$RXE_SAME" ] &&
+ [ "${returned#ibdev}" != "$returned" ]; then
+ ktap_test_pass "$TEST_TEARDOWN_RETURN"
+ else
+ ktap_test_fail "$TEST_TEARDOWN_RETURN"
+ fi
+fi
+cleanup_devs
+
+ktap_finished
|
| 3/2 | 2026/07/10 03:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 16509 output: 39 thoughts: 537 Thoughts: **RDMA Core and Cgroup Subsystem Changes: Reachability and Fuzzability Assessment** Okay, so I'm looking at this patch and it's making some pretty significant changes to the RDMA core and its cgroup integration. It's touching a lot of key areas, specifically the device naming and network namespace handling within the RDMA subsystem. I see modifications to functions like `ib_device_set_netns_put`, `rdma_dev_change_netns`, and the `alloc_name` function, along with alterations to `cgroup_rdma.h` and `cgroup/rdma.c` itself. It looks like it's making RDMA cgroups network namespace-aware, which is a big deal for isolation. I also see that it's restricting `smc_pnet_find_ib` to only see devices available in the network namespace through changes to `smc_pnet.c`. There are additions of `rxe_disassociate_ucontext` in `rxe_verbs.c`, and a new `srp_net_namespace` variable is added to `ib_srp.c`. Plus it's modifying `nldev.c` to allow passing a device name when changing netns. My immediate thought is, "Okay, this is a functional change. How reachable and fuzzable is this code?" We need to be able to hit this code path and verify its behavior with reasonable confidence. The main files of interest are `drivers/infiniband/core/device.c`, `drivers/infiniband/core/nldev.c`, and `kernel/cgroup/rdma.c`, as these are the ones that have been directly modified. Given the nature of these changes – adding netns support, potentially renaming devices per netns – this smells like a potential avenue for fuzzing, which is something I need to keep in mind. RDMA is definitely fuzzable given syzkaller coverage, so that's a good starting point. Now, let's figure out the relevant configuration options. I need to nail down exactly which `CONFIG_` options are required to enable the code paths affected by this patch. Specifically, I'm thinking about `CONFIG_CGROUP_RDMA` and `CONFIG_INFINIBAND`. And I know `CONFIG_RDMA_RXE` is used in the selftest. The `drivers/infiniband/core/device.c` is compiled when `CONFIG_INFINIBAND` is enabled. `kernel/cgroup/rdma.c` is enabled by `CONFIG_CGROUP_RDMA`, and `net/smc/smc_pnet.c` by `CONFIG_SMC`. `drivers/infiniband/sw/rxe/rxe_verbs.c` requires `CONFIG_RDMA_RXE` to be enabled, and `drivers/infiniband/ulp/srp/ib_srp.c` relies on `CONFIG_INFINIBAND_SRP`. I'll use `grepper` to get the exact configuration requirements for these paths and dependencies. |
| 4/2 | 2026/07/10 03:55 | tool | grepper |
0mArgs:{
"Expression": "^obj-\\$\\(CONFIG_CGROUP_RDMA\\)",
"PathPrefix": "kernel/cgroup/"
}Results: {
"Output": "kernel/cgroup/Makefile=5=obj-$(CONFIG_CGROUP_PIDS) += pids.o\nkernel/cgroup/Makefile:6:obj-$(CONFIG_CGROUP_RDMA) += rdma.o\nkernel/cgroup/Makefile-7-obj-$(CONFIG_CPUSETS) += cpuset.o\n"
} |
| 5/2 | 2026/07/10 03:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 17850 output: 40 thoughts: 16 Thoughts: Here's a first-person summary of the thought process, tailored for an expert audience: **Diving into the Infiniband Core Makefile** Okay, time to dig into this. I'm going to start with `drivers/infiniband/core/Makefile`. I need to get a handle on how this core module is built, and frankly, I expect this Makefile to be the heart of that. I'm going to be looking for the standard stuff: object file dependencies, include paths, maybe some arch-specific definitions if we're lucky, and of course, the linker flags. My gut says this will likely be a relatively straightforward Makefile; it's the core, so it should be well-organized and modular, right? Let's see if the build process utilizes the standard kernel build system variables and conventions. I'll be particularly interested in any conditional compilation flags. Are there any features I should be aware of or is it a fairly generic build for now? Let's get cracking. |
| 6/2 | 2026/07/10 03:55 | tool | grepper |
0mArgs:{
"Expression": "^obj-\\$\\(CONFIG_INFINIBAND\\)",
"PathPrefix": "drivers/infiniband/core/"
}Results: {
"Output": "drivers/infiniband/core/Makefile=3=user_access-$(CONFIG_INFINIBAND_ADDR_TRANS)\t:= rdma_ucm.o\ndrivers/infiniband/core/Makefile-4-\ndrivers/infiniband/core/Makefile:5:obj-$(CONFIG_INFINIBAND) +=\t\tib_core.o ib_cm.o iw_cm.o \\\ndrivers/infiniband/core/Makefile-6-\t\t\t\t\t$(infiniband-y)\n"
} |
| 7/2 | 2026/07/10 03:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 18246 output: 45 thoughts: 19 Thoughts: Here's my take on the thought process, as if it were my own: **Diving into the RXE Makefile** Okay, time to get my hands dirty. I need to understand how the RXE (Reliable eXpress Ethernet) driver's build process is structured within the Infiniband subsystem. My first step is to zero in on the `drivers/infiniband/sw/rxe/Makefile`. That's where all the build magic for this module should be defined. I'm expecting to see the usual suspects: object file targets, dependencies, compiler flags, and linking rules. Hopefully, it's well-organized and doesn't involve any overly convoluted or obscure makefile tricks. I'm keen to see if they're using any specific kernel features or tools during the build process. I'll be looking for clues on how they handle things like header inclusion, module dependencies on other parts of the kernel, and any special options or libraries they're linking against. Let's see what's in store. |
| 8/2 | 2026/07/10 03:55 | tool | grepper |
0mArgs:{
"Expression": "^obj-\\$\\(CONFIG_RDMA_RXE\\)",
"PathPrefix": "drivers/infiniband/sw/rxe/"
}Results: {
"Output": "drivers/infiniband/sw/rxe/Makefile-1-# SPDX-License-Identifier: GPL-2.0\ndrivers/infiniband/sw/rxe/Makefile:2:obj-$(CONFIG_RDMA_RXE) += rdma_rxe.o\ndrivers/infiniband/sw/rxe/Makefile-3-\n"
} |
| 9/2 | 2026/07/10 03:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 18624 output: 45 thoughts: 19 Thoughts: Here's a first-person summary, tailored for an expert audience, of the thought process described: **Diving into the SRP Makefile** Okay, time to get my hands dirty. Let's start by zeroing in on the `drivers/infiniband/ulp/srp/Makefile`. That's where the heart of the SRP (SCSI RDMA Protocol) driver within the Infiniband stack will be. I need to understand how the build system integrates this specific ULP (Upper Layer Protocol) into the kernel image. I want to see how the object files are compiled, any dependencies it has on other Infiniband components, and if there are any custom build flags or linker directives specific to SRP. Understanding this Makefile is crucial for debugging potential issues, for making customizations, and for verifying how this module is built within the context of the larger IB stack. I'm expecting to see things like object file definitions, includes of other relevant headers within the same directory or from higher in the IB structure, and conditional compilation based on kernel configuration options. Let's see what's there... |
| 10/2 | 2026/07/10 03:55 | tool | grepper |
0mArgs:{
"Expression": "^obj-\\$\\(CONFIG_INFINIBAND_SRP\\)",
"PathPrefix": "drivers/infiniband/ulp/srp/"
}Results: {
"Output": "drivers/infiniband/ulp/srp/Kbuild-1-# SPDX-License-Identifier: GPL-2.0\ndrivers/infiniband/ulp/srp/Kbuild:2:obj-$(CONFIG_INFINIBAND_SRP)\t\t\t+= ib_srp.o\n"
} |
| 11/2 | 2026/07/10 03:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 18996 output: 35 thoughts: 12 Thoughts: Here's a summary of my thought process, as if I were the one thinking it: **Diving into the Makefile** Alright, time to dig in. The problem likely lies within the network stack's handling of SMC (Shared Memory Communication), so let's start with the `net/smc/Makefile`. This is the most logical place to begin investigating the build process and dependencies for anything related to SMC functionality. By examining this Makefile, I can get a clear picture of how SMC modules are compiled, linked, and incorporated into the kernel or relevant network components. It'll reveal any conditional compilation flags, potential target-specific settings, and most importantly, any areas where there might be misconfigurations or overlooked dependencies that are causing issues with the SMC implementation. This will hopefully provide a fast path to understanding the build environment for this feature. |
| 12/2 | 2026/07/10 03:55 | tool | grepper |
0mArgs:{
"Expression": "^obj-\\$\\(CONFIG_SMC\\)",
"PathPrefix": "net/smc/"
}Results: {
"Output": "net/smc/Makefile=2=ccflags-y += -I$(src)\nnet/smc/Makefile:3:obj-$(CONFIG_SMC)\t+= smc.o\nnet/smc/Makefile-4-obj-$(CONFIG_SMC_DIAG)\t+= smc_diag.o\n"
} |
| 13/2 | 2026/07/10 03:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 19303 output: 42 thoughts: 205 Thoughts: **Analyzing the Network Namespace Patch** Okay, so this patch is touching a number of key functions related to network namespaces and RDMA. I see it's modifying `ib_device_set_netns_put`, `rdma_dev_change_netns`, `rdma_dev_pick_netns_name`, `nldev_set_doit`, `rdmacg_device_visible`, `smc_pnet_find_ib`, and `srp_net_namespace`. Right away, this tells me we're looking at potentially significant changes to how RDMA devices are handled within different network contexts. My primary concern, as always, is the impact on stability and performance. My immediate focus, based on these function names, is how the device is moved between namespaces, how it picks the correct namespace name, and how its visibility is determined within the RDMA ecosystem. I will pay particularly close attention to `ib_device_set_netns_put`, `rdma_dev_change_netns`, `rdma_dev_pick_netns_name`, `nldev_set_doit`, `rdmacg_device_visible`, `smc_pnet_find_ib`, and `srp_net_namespace`. I'll need to scrutinize how these changes interact with the existing device management and netlink interfaces. Also, I need to check `nldev_set_doit` and ensure that it is the accurate name. I'll need to verify that it is not a typo or placeholder. |
| 14/2 | 2026/07/10 03:55 | tool | grepper |
0mArgs:{
"Expression": "nldev_set_doit",
"PathPrefix": "drivers/infiniband/core/nldev.c"
}Results: {
"Output": "drivers/infiniband/core/nldev.c=1112=static int nldev_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,\n--\ndrivers/infiniband/core/nldev.c-1161-\ndrivers/infiniband/core/nldev.c:1162:static int nldev_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,\ndrivers/infiniband/core/nldev.c-1163-\t\t\t struct netlink_ext_ack *extack)\n--\ndrivers/infiniband/core/nldev.c=2970=static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {\n--\ndrivers/infiniband/core/nldev.c-2978-\t[RDMA_NLDEV_CMD_SET] = {\ndrivers/infiniband/core/nldev.c:2979:\t\t.doit = nldev_set_doit,\ndrivers/infiniband/core/nldev.c-2980-\t\t.flags = RDMA_NL_ADMIN_PERM,\n"
} |
| 15/2 | 2026/07/10 03:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 20211 output: 36 thoughts: 29 Thoughts: Okay, here's my summarized thought process, presented as if I were thinking it: **Verifying the Setup** Alright, that initial assessment of `nldev_set_doit` is spot on, seems like we're good to go there. Now, let's just do a quick sanity check on `rdmacg_device_visible`. Want to make sure everything's aligned and we didn't miss anything fundamental in the initial setup. I always like to double-check these base assumptions. |
| 16/2 | 2026/07/10 03:56 | tool | grepper |
0mArgs:{
"Expression": "rdmacg_device_visible",
"PathPrefix": "kernel/cgroup/rdma.c"
}Results: {
"Output": "kernel/cgroup/rdma.c=466=EXPORT_SYMBOL(rdmacg_unregister_device);\n--\nkernel/cgroup/rdma.c-468-/* netns_shared is toggled without rdmacg_mutex, hence READ_ONCE(). */\nkernel/cgroup/rdma.c:469:static bool rdmacg_device_visible(const struct rdmacg_device *device)\nkernel/cgroup/rdma.c-470-{\n--\nkernel/cgroup/rdma.c=475=static struct rdmacg_device *rdmacg_get_device_locked(const char *name)\n--\nkernel/cgroup/rdma.c-481-\tlist_for_each_entry(device, \u0026rdmacg_devices, dev_node)\nkernel/cgroup/rdma.c:482:\t\tif (rdmacg_device_visible(device) \u0026\u0026\nkernel/cgroup/rdma.c-483-\t\t !strcmp(name, device-\u003ename))\n--\nkernel/cgroup/rdma.c=629=static int rdmacg_resource_read(struct seq_file *sf, void *v)\n--\nkernel/cgroup/rdma.c-637-\tlist_for_each_entry(device, \u0026rdmacg_devices, dev_node) {\nkernel/cgroup/rdma.c:638:\t\tif (!rdmacg_device_visible(device))\nkernel/cgroup/rdma.c-639-\t\t\tcontinue;\n--\nkernel/cgroup/rdma.c=653=static int rdmacg_events_show(struct seq_file *sf, void *v)\n--\nkernel/cgroup/rdma.c-662-\tlist_for_each_entry(device, \u0026rdmacg_devices, dev_node) {\nkernel/cgroup/rdma.c:663:\t\tif (!rdmacg_device_visible(device))\nkernel/cgroup/rdma.c-664-\t\t\tcontinue;\n--\nkernel/cgroup/rdma.c=685=static int rdmacg_events_local_show(struct seq_file *sf, void *v)\n--\nkernel/cgroup/rdma.c-694-\tlist_for_each_entry(device, \u0026rdmacg_devices, dev_node) {\nkernel/cgroup/rdma.c:695:\t\tif (!rdmacg_device_visible(device))\nkernel/cgroup/rdma.c-696-\t\t\tcontinue;\n"
} |
| 17/2 | 2026/07/10 03:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 21022 output: 41 thoughts: 93 Thoughts: Okay, let's see, my thinking right now is centered on this `rdmacg_device_visible` function. Since it's static, including it seems safe enough. I should also consider whether to bring in `rdmacg_get_device_locked`, `rdmacg_resource_read`, `rdmacg_events_show`, and `rdmacg_events_local_show`. Wait, on second thought, `rdmacg_device_visible` should be perfectly adequate on its own for the current purpose. Now, I'll switch gears to examine `smc_pnet_find_ib`. Let's take a look. |
| 18/2 | 2026/07/10 03:56 | tool | grepper |
0mArgs:{
"Expression": "smc_pnet_find_ib",
"PathPrefix": "net/smc/smc_pnet.c"
}Results: {
"Output": "net/smc/smc_pnet.c=285=static bool smc_pnetid_valid(const char *pnet_name, char *pnetid)\n--\nnet/smc/smc_pnet.c-310- */\nnet/smc/smc_pnet.c:311:static struct smc_ib_device *smc_pnet_find_ib(struct net *net, char *ib_name)\nnet/smc/smc_pnet.c-312-{\n--\nnet/smc/smc_pnet.c=416=static int smc_pnet_add_ib(struct smc_pnettable *pnettable, struct net *net,\n--\nnet/smc/smc_pnet.c-426-\t/* try to apply the pnetid to active devices */\nnet/smc/smc_pnet.c:427:\tib_dev = smc_pnet_find_ib(net, ib_name);\nnet/smc/smc_pnet.c-428-\tif (ib_dev) {\n"
} |
| 19/2 | 2026/07/10 03:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 21588 output: 44 thoughts: 12 Thoughts: Here's my take on those thoughts: **Checking the `srp_net_namespace`** Okay, so I need to take a look at `srp_net_namespace`. It's a key piece of the puzzle, and I need to assess its current state and how it's interacting with the broader network configuration. I want to quickly evaluate the settings to ensure that it's consistent with my overall architectural design and that it's functioning as expected, especially in relation to the Secure Remote Password (SRP) network. No point in proceeding without this base being strong. Let's delve in and find out what we're working with. |
| 20/2 | 2026/07/10 03:56 | tool | grepper |
0mArgs:{
"Expression": "srp_net_namespace",
"PathPrefix": "drivers/infiniband/ulp/srp/ib_srp.c"
}Results: {
"Output": "drivers/infiniband/ulp/srp/ib_srp.c=3190=ATTRIBUTE_GROUPS(srp_class);\n--\ndrivers/infiniband/ulp/srp/ib_srp.c-3195- */\ndrivers/infiniband/ulp/srp/ib_srp.c:3196:static const struct ns_common *srp_net_namespace(const struct device *dev)\ndrivers/infiniband/ulp/srp/ib_srp.c-3197-{\n--\ndrivers/infiniband/ulp/srp/ib_srp.c=3204=static struct class srp_class = {\n--\ndrivers/infiniband/ulp/srp/ib_srp.c-3208-\t.ns_type = \u0026net_ns_type_operations,\ndrivers/infiniband/ulp/srp/ib_srp.c:3209:\t.namespace = srp_net_namespace,\ndrivers/infiniband/ulp/srp/ib_srp.c-3210-};\n"
} |
| 21/2 | 2026/07/10 03:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 22067 output: 38 thoughts: 12 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary: **Digging into Memory Allocation Naming** Alright, so the task at hand… let's dive right in. The immediate thing that pops into my mind is to zero in on `__alloc_name_id`. It’s the obvious first point of investigation, isn’t it? Any time I see a memory allocation-related issue, understanding how allocation names are handled, or rather, the internal ID generation, becomes paramount. A lot of subtle problems can stem from mismanaged names, particularly in complex, multithreaded systems. So, my initial thought? Let's verify how that particular function behaves, make sure the ID's are correctly set and managed. This will be the first step in my analysis. It's the lynchpin for tracking and debugging potential naming collisions or leaks. Understanding its behaviour is the baseline for anything else. |
| 22/2 | 2026/07/10 03:56 | tool | grepper |
0mArgs:{
"Expression": "__alloc_name_id",
"PathPrefix": "drivers/infiniband/core/device.c"
}Results: {
"Output": "drivers/infiniband/core/device.c=432=int ib_device_set_dim(struct ib_device *ibdev, u8 use_dim)\n--\ndrivers/infiniband/core/device.c-445- */\ndrivers/infiniband/core/device.c:446:static int __alloc_name_id(struct net *net, const char *name,\ndrivers/infiniband/core/device.c-447-\t\t\t const struct ib_device *skip)\n--\ndrivers/infiniband/core/device.c=481=static int alloc_name_id(struct net *net, const char *name)\ndrivers/infiniband/core/device.c-482-{\ndrivers/infiniband/core/device.c:483:\treturn __alloc_name_id(net, name, NULL);\ndrivers/infiniband/core/device.c-484-}\n--\ndrivers/infiniband/core/device.c=1739=static int rdma_dev_pick_netns_name(struct ib_device *device, struct net *net,\n--\ndrivers/infiniband/core/device.c-1771-\ndrivers/infiniband/core/device.c:1772:\tid = __alloc_name_id(net, fallback_pattern, device);\ndrivers/infiniband/core/device.c-1773-\tif (id \u003c 0)\n"
} |
| 23/2 | 2026/07/10 03:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 22700 output: 43 thoughts: 17 Thoughts: Okay, here's my attempt at summarizing that thought process, tailored for an expert audience: **Checking `rdma_dev_name_in_netns`** Right, let's dive straight in. I need to take a look at `rdma_dev_name_in_netns`. I know this function/variable/mechanism (context depending, naturally) is crucial for ensuring the correct behavior of RDMA devices within network namespaces. I'm probably dealing with an issue related to device visibility or perhaps cross-namespace communication and I need to quickly establish if this is the root cause. This implies I'm either debugging a live system, examining code, or reviewing a potential patch/configuration. I'll be looking for where it's defined, how it's used, and what its potential side effects are. I'll likely be assessing its role in device enumeration, permission checks, or resource allocation. The specifics will vary depending on the kernel version and the particular RDMA stack in question, but the core focus will be on understanding how network namespace isolation is (or isn't) handled with respect to RDMA device naming. This is probably a good starting point to eliminate the simple possibilities and to dig into the details. |
| 24/2 | 2026/07/10 03:56 | tool | grepper |
0mArgs:{
"Expression": "rdma_dev_name_in_netns",
"PathPrefix": "drivers/infiniband/core/device.c"
}Results: {
"Output": "drivers/infiniband/core/device.c=1714=EXPORT_SYMBOL(ib_unregister_device_queued);\ndrivers/infiniband/core/device.c-1715-\ndrivers/infiniband/core/device.c:1716:static bool rdma_dev_name_in_netns(struct ib_device *skip, struct net *net,\ndrivers/infiniband/core/device.c-1717-\t\t\t\t const char *name)\n--\ndrivers/infiniband/core/device.c=1739=static int rdma_dev_pick_netns_name(struct ib_device *device, struct net *net,\n--\ndrivers/infiniband/core/device.c-1749-\tif (requested_name) {\ndrivers/infiniband/core/device.c:1750:\t\tif (!rdma_dev_name_in_netns(device, net, requested_name)) {\ndrivers/infiniband/core/device.c-1751-\t\t\t*new_name = requested_name;\n--\ndrivers/infiniband/core/device.c-1757-\ndrivers/infiniband/core/device.c:1758:\tif (!rdma_dev_name_in_netns(device, net, dev_name(\u0026device-\u003edev))) {\ndrivers/infiniband/core/device.c-1759-\t\t*new_name = dev_name(\u0026device-\u003edev);\n--\ndrivers/infiniband/core/device.c-1766-\tsnprintf(buf, buf_len, \"ibdev%u\", device-\u003eindex);\ndrivers/infiniband/core/device.c:1767:\tif (!rdma_dev_name_in_netns(device, net, buf)) {\ndrivers/infiniband/core/device.c-1768-\t\t*new_name = buf;\n"
} |
| 25/2 | 2026/07/10 03:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 23510 output: 29 thoughts: 181 Thoughts: **RDMA Net Namespace Patch: Initial Assessment** Okay, so this patch introduces net namespace support for RDMA devices. Essentially, it allows these devices to have unique names within each network namespace, which seems like a pretty significant functional change, especially considering it touches both the core RDMA subsystem and cgroups. My immediate thought is, this is *definitely* worth a thorough fuzzing campaign. The potential for unexpected interactions and corner cases is high with this level of core modification. Now, let's nail down the configuration requirements to ensure a proper test environment. Based on the description, we'll need to enable `CGROUP_RDMA`, `INFINIBAND`, `NET_NS`, `SMC`, and `INFINIBAND_SRP`. I should probably double-check if `NET_NS` is absolutely required or if it's usually compiled in already, which is likely. `CGROUP_RDMA` seems essential for the cgroup-related modifications, and `INFINIBAND` is obviously necessary for the core RDMA changes. The presence of `SMC` indicates likely changes to the Shared Memory Communications. Finally, `INFINIBAND_SRP` is required for the SRP changes. I'll need to do a quick scan on `CONFIG_SMC` to confirm if it makes sense in the current context. |
| 26/2 | 2026/07/10 03:56 | tool | grepper |
0mArgs:{
"Expression": "config SMC",
"PathPrefix": "net/smc/Kconfig"
}Results: {
"Output": "net/smc/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\nnet/smc/Kconfig:2:config SMC\nnet/smc/Kconfig-3-\ttristate \"SMC socket protocol family\"\n--\nnet/smc/Kconfig-13-\nnet/smc/Kconfig:14:config SMC_DIAG\nnet/smc/Kconfig-15-\ttristate \"SMC: socket monitoring interface\"\n--\nnet/smc/Kconfig-22-\nnet/smc/Kconfig:23:config SMC_HS_CTRL_BPF\nnet/smc/Kconfig-24-\tbool \"Generic eBPF hook for SMC handshake flow\"\n"
} |
| 27/2 | 2026/07/10 03:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 24186 output: 40 thoughts: 13 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Checking the InfiniBand SRP Configuration** Right, let's dive straight in. My immediate thought is, "Okay, we're looking at `CONFIG_INFINIBAND_SRP`". That immediately signals we're dealing with Serialized Reserve Protocol, which of course I'm intimately familiar with. The focus here is likely on how it's being configured, or perhaps whether it *is* configured. Are we trying to enable it, disable it, or simply audit its current state? The context here is key. I'm already mentally running through the implications: potential impact on storage performance, the interplay with other InfiniBand options like RDMA and verbs, and the overall system architecture. Where are we running? What's the target platform? Knowing this will significantly affect how I interpret this simple check. Depending on the environment, my next step could be to verify module loading, check associated kernel parameters, or review existing block device settings. |
| 28/2 | 2026/07/10 03:56 | tool | grepper |
0mArgs:{
"Expression": "config INFINIBAND_SRP",
"PathPrefix": "drivers/infiniband/ulp/srp/Kconfig"
}Results: {
"Output": "drivers/infiniband/ulp/srp/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/infiniband/ulp/srp/Kconfig:2:config INFINIBAND_SRP\ndrivers/infiniband/ulp/srp/Kconfig-3-\ttristate \"InfiniBand SCSI RDMA Protocol\"\n"
} |
| 29/2 | 2026/07/10 03:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 24553 output: 31 thoughts: 14 Thoughts: Okay, here's my interpretation of that thought process, assuming I'm an expert in this field, presented as a first-person summary: **Checking the RDMA Cgroup Configuration** Alright, before diving too deep into this RDMA-related issue, I need to verify something fundamental. My initial instinct is to make sure we haven't overlooked a basic configuration parameter. The first thing I'm going to do is check the state of `CONFIG_CGROUP_RDMA`. It's a critical knob when working with RDMA within cgroups. If it's disabled, then most of my efforts will be hampered from the start. I want to rule out a simple misconfiguration before I start troubleshooting the complexities that might follow. This is the low-hanging fruit, so to speak, and I'd be remiss not to eliminate it as a primary cause. Time to see what that setting is! |
| 30/2 | 2026/07/10 03:56 | tool | grepper |
0mArgs:{
"Expression": "config CGROUP_RDMA",
"PathPrefix": "init/Kconfig"
}Results: {
"Output": "init/Kconfig=1237=config CGROUP_PIDS\n--\ninit/Kconfig-1252-\ninit/Kconfig:1253:config CGROUP_RDMA\ninit/Kconfig-1254-\tbool \"RDMA controller\"\n"
} |
| 31/2 | 2026/07/10 03:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 24869 output: 40 thoughts: 13 Thoughts: Okay, here's my interpretation of that thought process, assuming I'm deep in the weeds of network configuration: **Checking `CONFIG_RDMA_RXE`** Right, let's dive in. I need to make sure `CONFIG_RDMA_RXE` is correctly set. This is a critical configuration option. It's the lynchpin for Receiver Extensions (RXE) support in our RDMA setup. This parameter is the deciding factor for whether or not we can enable the RXE functionality; without it enabled we’re sunk. I immediately need to confirm its value, because if it's not set correctly, then whatever I'm troubleshooting, or configuring, isn't going to work. Is it enabled? Disabled? Set as a module? The nuances there can dramatically shift how I need to proceed and what I may be encountering. If it's disabled, I know to pursue other avenues and solutions that are compatible without RXE, but, if enabled, I know I'm on the right track. This option will influence other dependencies, and I'll need to remember to account for that. |
| 32/2 | 2026/07/10 03:56 | tool | grepper |
0mArgs:{
"Expression": "config RDMA_RXE",
"PathPrefix": "drivers/infiniband/sw/rxe/Kconfig"
}Results: {
"Output": "drivers/infiniband/sw/rxe/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/infiniband/sw/rxe/Kconfig:2:config RDMA_RXE\ndrivers/infiniband/sw/rxe/Kconfig-3-\ttristate \"Software RDMA over Ethernet (RoCE) driver\"\n"
} |
| 33/2 | 2026/07/10 03:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 25261 output: 234 thoughts: 269 Thoughts: **Analyzing the RDMA Network Namespace Patch** Okay, let's break down this patch. My immediate thought is to understand the scope of changes, so I see it touches a wide range of RDMA-related code: `drivers/infiniband/core/device.c`, `drivers/infiniband/core/nldev.c`, `kernel/cgroup/rdma.c`, `net/smc/smc_pnet.c`, `drivers/infiniband/sw/rxe/rxe_verbs.c`, and `drivers/infiniband/ulp/srp/ib_srp.c`. That's a pretty diverse set of areas – core device handling, network device configuration, cgroup integration, SMC, SRP, and even RXE. I’ll need to understand how these pieces fit together. My next step is to zero in on the key symbols this patch modifies. I'm seeing `ib_device_set_netns_put`, `rdma_dev_change_netns`, `rdma_dev_pick_netns_name`, `nldev_set_doit`, `rdmacg_device_visible`, `smc_pnet_find_ib`, `srp_net_namespace`, `__alloc_name_id`, and `rdma_dev_name_in_netns`. These are all crucial for network namespace interaction with RDMA devices. The fact that the changes involve name allocation (`__alloc_name_id`, `rdma_dev_pick_netns_name`, `rdma_dev_name_in_netns`) and visibility checks (`rdmacg_device_visible`) suggests significant work on how RDMA devices and their names are managed within different network namespaces. The `ib_device_set_netns_put` and `rdma_dev_change_netns` functions are also critically important. Looking at the configurations affected, `INFINIBAND`, `CGROUP_RDMA`, `SMC`, `INFINIBAND_SRP`, and `RDMA_RXE` tells me that this patch is touching a good chunk of the RDMA feature set. I need to be sure the interaction between all of these features is correct. Alright, I've got a decent grasp of the "what." Now, it's time to dive into the code and understand *how* these functions are being modified and *why* these changes are needed to ensure proper network namespace behavior. I need to understand how these symbols interact in the overall device management, cgroup integration, and SMC/SRP support. I'm going to dig into the details and then compare this with previous patches. Now, I will call `set-results`. |
| 34/2 | 2026/07/10 03:56 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"INFINIBAND",
"CGROUP_RDMA",
"SMC",
"INFINIBAND_SRP",
"RDMA_RXE"
],
"FocusSymbols": [
"ib_device_set_netns_put",
"rdma_dev_change_netns",
"rdma_dev_pick_netns_name",
"nldev_set_doit",
"rdmacg_device_visible",
"smc_pnet_find_ib",
"srp_net_namespace",
"__alloc_name_id",
"rdma_dev_name_in_netns"
],
"Reasoning": "The patch introduces net namespace support for RDMA devices, allowing them to be isolated and renamed per network namespace. This involves functional changes to the RDMA core, RDMA cgroups, SMC, and SRP. These changes are reachable from userspace via netlink and cgroupfs, and thus should be fuzzed.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"INFINIBAND",
"CGROUP_RDMA",
"SMC",
"INFINIBAND_SRP",
"RDMA_RXE"
],
"FocusSymbols": [
"ib_device_set_netns_put",
"rdma_dev_change_netns",
"rdma_dev_pick_netns_name",
"nldev_set_doit",
"rdmacg_device_visible",
"smc_pnet_find_ib",
"srp_net_namespace",
"__alloc_name_id",
"rdma_dev_name_in_netns"
],
"Reasoning": "The patch introduces net namespace support for RDMA devices, allowing them to be isolated and renamed per network namespace. This involves functional changes to the RDMA core, RDMA cgroups, SMC, and SRP. These changes are reachable from userspace via netlink and cgroupfs, and thus should be fuzzed.",
"WorthFuzzing": true
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|