Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Md Haris Iqbal" <haris.iqbal@ionos.com>, linux-rdma@vger.kernel.org
Subject: Re: [PATCH 5/9] RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open()
Date: Mon, 23 Nov 2026 14:42:35 +0000	[thread overview]
Message-ID: <sashiko-outbox-229434@kernel.org> (raw)
In-Reply-To: <20261123143719.938876-6-haris.iqbal@ionos.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] RDMA/rtrs-clt: use-after-free in rtrs_clt_open() [1]
--

commit d270a6058ae45a4fbd952be02c065eb235215fda
Author: Danil Kipnis <danil.kipnis1@ionos.com>

RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open()

This commit renames the pathname parameter of rtrs_clt_open() to sessname
in the header declaration and implementation.

> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index 5ef912a472cda..c059d69c3e5a3 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c

[ ... ]

> @@ -2848,7 +2848,7 @@ static void free_clt(struct rtrs_clt_sess *clt)
>   * Return a valid pointer on success otherwise PTR_ERR.
>   */
>  struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
> -				 const char *pathname,
> +				 const char *sessname,
>  				 const struct rtrs_addr *paths,
>  				 size_t paths_num, u16 port,
>  				 size_t pdu_sz, u8 reconnect_delay_sec,
> @@ -2858,13 +2858,13 @@ struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
>  	struct rtrs_clt_sess *clt;
>  	int err, i;
>  
> -	if (strchr(pathname, '/') || strchr(pathname, '.')) {
> -		pr_err("pathname cannot contain / and .\n");
> +	if (strchr(sessname, '/') || strchr(sessname, '.')) {
> +		pr_err("sessname cannot contain / and .\n");
>  		err = -EINVAL;
>  		goto out;
>  	}
>  
> -	clt = alloc_clt(pathname, paths_num, port, pdu_sz, ops->priv,
> +	clt = alloc_clt(sessname, paths_num, port, pdu_sz, ops->priv,
>  			ops->link_ev,
>  			reconnect_delay_sec,
>  			max_reconnect_attempts);

[Severity: Critical]
This problem wasn't introduced by this patch, but can a failure in
rtrs_clt_create_path_files() later in rtrs_clt_open() cause a
use-after-free and double free of clt_path [1]?

When kobject_init_and_add() fails in rtrs_clt_create_path_files(), it
calls kobject_put(&clt_path->kobj), which invokes rtrs_clt_path_release()
and frees clt_path via free_path():

drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c:rtrs_clt_create_path_files() {
    ...
	err = kobject_init_and_add(&clt_path->kobj, &ktype_sess,
				   clt->kobj_paths,
				   "%s", str);
	if (err) {
		pr_err("kobject_init_and_add: %pe\n", ERR_PTR(err));
		kobject_put(&clt_path->kobj);
		return err;
	}
    ...
}

rtrs_clt_open() then touches the freed clt_path in list_del_rcu(),
rtrs_clt_close_conns(), and free_percpu() before calling free_path() a
second time:

drivers/infiniband/ulp/rtrs/rtrs-clt.c:rtrs_clt_open() {
    ...
		err = rtrs_clt_create_path_files(clt_path);
		if (err) {
			list_del_rcu(&clt_path->s.entry);
			rtrs_clt_close_conns(clt_path, true);
			free_percpu(clt_path->stats->pcpu_stats);
			free_path(clt_path);
			goto close_all_path;
		}
    ...
}

[1] https://sashiko.dev/#/bug/linux-982ecccb-b1ca-401f-8293-d1973992f3f6

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123143719.938876-1-haris.iqbal@ionos.com?part=5

  reply	other threads:[~2026-11-23 14:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 1/9] RDMA/rtrs-clt: Add mpath_policy module parameter Md Haris Iqbal
2026-11-23 14:44   ` sashiko-bot
2026-11-23 14:37 ` [PATCH 2/9] RDMA/rtrs-clt: Fix refcount imbalance in rtrs_clt_write_req error path Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 3/9] RDMA/rtrs-clt: Trigger error recovery when posting LOCAL_INV fails Md Haris Iqbal
2026-11-23 15:02   ` sashiko-bot
2026-11-23 14:37 ` [PATCH 4/9] RDMA/rtrs-srv: Fix processing messages for Big-Endian archs Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 5/9] RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open() Md Haris Iqbal
2026-11-23 14:42   ` sashiko-bot [this message]
2026-11-23 14:37 ` [PATCH 6/9] RDMA/rtrs-clt: Fix reconnect jitter being applied in milliseconds Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 7/9] RDMA/rtrs-clt: Back off the reconnect delay exponentially Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 8/9] RDMA/rtrs-srv: Snapshot the READ request header instead of reusing it Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 9/9] RDMA/rtrs-clt: Close all paths before freeing any in rtrs_clt_close() Md Haris Iqbal
2026-11-23 15:02 ` [PATCH 0/9] Misc patches for RTRS sashiko-bot

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=sashiko-outbox-229434@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=haris.iqbal@ionos.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox