[PATCH 3/3] RDMA/rtrs-srv: Reject an empty pathname
From: Yuqiang Sun
Date: Thu Oct 29 2026 - 00:28:36 EST
process_info_req() uses the pathname sent by the client as the name of
the session device and rejects names containing '/' or '.', but it
accepts an empty one. dev_set_name() succeeds for it, and device_add()
then fails in kobject_add_internal(), which warns about the empty name.
Reject an empty pathname together with the other invalid ones.
Build-tested with x86_64 and arm64 allmodconfig (W=1, sparse): no new
warnings. Run-tested under KVM with KASAN, lockdep and kmemleak, using
a small user-space rtrs client that sends an empty pathname: the server
now rejects it at the check above, nothing is reported, and an ordinary
rnbd map, I/O and unmap afterwards still work. Not tested on RDMA
hardware.
Fixes: dea7bb3ad3e0 ("RDMA/rtrs: Do not allow sessname to contain special symbols / and .")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: Claude:claude-opus-5-5 kbound
Signed-off-by: Yuqiang Sun <izaiahsun@xxxxxxxxx>
---
drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
index 56f0ab5a7619..d34a177f7ba2 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
@@ -823,6 +823,10 @@ static int process_info_req(struct rtrs_srv_con *con,
return err;
}
+ if (!msg->pathname[0]) {
+ rtrs_err(s, "pathname cannot be empty\n");
+ return -EINVAL;
+ }
if (strchr(msg->pathname, '/') || strchr(msg->pathname, '.')) {
rtrs_err(s, "pathname cannot contain / and .\n");
return -EINVAL;
--
2.53.0