From: Guangshuo Li <lgs201920130244@gmail.com>
To: "Md. Haris Iqbal" <haris.iqbal@ionos.com>,
Jack Wang <jinpu.wang@ionos.com>, Jason Gunthorpe <jgg@ziepe.ca>,
Leon Romanovsky <leon@kernel.org>,
Vaishali Thakkar <vaishali.thakkar@ionos.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Guangshuo Li <lgs201920130244@gmail.com>
Subject: [PATCH v2] RDMA/rtrs: Fix use-after-free in path files cleanup
Date: Mon, 11 May 2026 21:08:04 +0800 [thread overview]
Message-ID: <20260511130804.773204-1-lgs201920130244@gmail.com> (raw)
Once kobject_put() is called on srv_path->kobj, the release callback may be
triggered and srv_path may be freed. Therefore, srv_path must not be used
after kobject_put(&srv_path->kobj).
Both rtrs_srv_create_path_files() and rtrs_srv_destroy_path_files()
currently call rtrs_srv_destroy_once_sysfs_root_folders(srv_path) after
kobject_put(&srv_path->kobj). Although the call site only passes srv_path
as an argument, rtrs_srv_destroy_once_sysfs_root_folders() dereferences it
internally to access srv_path->srv. If kobject_put() has already freed
srv_path, this results in a use-after-free.
Move rtrs_srv_destroy_once_sysfs_root_folders() before kobject_put(), so
srv_path remains valid while the helper accesses it.
This issue was found by a static analysis tool I am developing.
Fixes: ae4c81644e91 ("RDMA/rtrs-srv: Rename rtrs_srv_sess to rtrs_srv_path")
Acked-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
v2:
- Clarify that the use-after-free happens inside
rtrs_srv_destroy_once_sysfs_root_folders(), which dereferences srv_path
after kobject_put() may have freed it.
- No code changes.
drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
index 51727c7d710c..c9ba9d2d0eb3 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
@@ -295,8 +295,8 @@ int rtrs_srv_create_path_files(struct rtrs_srv_path *srv_path)
put_kobj:
kobject_del(&srv_path->kobj);
destroy_root:
- kobject_put(&srv_path->kobj);
rtrs_srv_destroy_once_sysfs_root_folders(srv_path);
+ kobject_put(&srv_path->kobj);
return err;
}
@@ -312,8 +312,8 @@ void rtrs_srv_destroy_path_files(struct rtrs_srv_path *srv_path)
if (srv_path->kobj.state_in_sysfs) {
sysfs_remove_group(&srv_path->kobj, &rtrs_srv_path_attr_group);
- kobject_put(&srv_path->kobj);
rtrs_srv_destroy_once_sysfs_root_folders(srv_path);
+ kobject_put(&srv_path->kobj);
}
}
--
2.43.0
next reply other threads:[~2026-05-11 13:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 13:08 Guangshuo Li [this message]
2026-05-14 7:17 ` [PATCH v2] RDMA/rtrs: Fix use-after-free in path files cleanup Leon Romanovsky
2026-05-14 11:31 ` Guangshuo Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260511130804.773204-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=haris.iqbal@ionos.com \
--cc=jgg@ziepe.ca \
--cc=jinpu.wang@ionos.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=vaishali.thakkar@ionos.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.