public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Md Haris Iqbal <haris.iqbal@ionos.com>,
	Grzegorz Prajsner <grzegorz.prajsner@ionos.com>,
	Jack Wang <jinpu.wang@ionos.com>,
	Leon Romanovsky <leon@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-rdma@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19-5.15] RDMA/rtrs-clt: For conn rejection use actual err number
Date: Sun, 15 Feb 2026 10:03:27 -0500	[thread overview]
Message-ID: <20260215150333.2150455-10-sashal@kernel.org> (raw)
In-Reply-To: <20260215150333.2150455-1-sashal@kernel.org>

From: Md Haris Iqbal <haris.iqbal@ionos.com>

[ Upstream commit fc290630702b530c2969061e7ef0d869a5b6dc4f ]

When the connection establishment request is rejected from the server
side, then the actual error number sent back should be used.

Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Link: https://patch.msgid.link/20260107161517.56357-10-haris.iqbal@ionos.com
Reviewed-by: Grzegorz Prajsner <grzegorz.prajsner@ionos.com>
Reviewed-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

## Analysis of RDMA/rtrs-clt: For conn rejection use actual err number

### Commit Message Analysis

The commit message says: "When the connection establishment request is
rejected from the server side, then the actual error number sent back
should be used." This is a bug fix — the function was discarding the
server-provided error code and always returning `-ECONNRESET`,
regardless of what the server actually reported.

### Code Change Analysis

The change is small and surgical, touching only the
`rtrs_rdma_conn_rejected()` function in
`drivers/infiniband/ulp/rtrs/rtrs-clt.c`:

1. **Initialization change**: `int status, errno;` → `int status, errno
   = -ECONNRESET;` — initializes `errno` to the previous hard-coded
   return value as a default.

2. **Return value change**: `return -ECONNRESET;` → `return errno;` —
   now returns the actual error number from the server's rejection
   message.

**What this fixes**: Previously, when the server rejected a connection
and sent back a specific error code (e.g., `-EBUSY`), the function would
parse and log the error correctly but then discard it, always returning
`-ECONNRESET`. This means the caller couldn't distinguish between
different rejection reasons. The most important case is `-EBUSY`, which
tells the client that a previous session still exists and it should
reconnect later — with the old code, the caller couldn't differentiate
this from a generic connection reset.

**Fallback behavior**: If the rejection message is malformed or too
short (`else` branch), `errno` retains its default `-ECONNRESET` value,
preserving the old behavior for that case. This is clean and safe.

### Bug Classification

This is a **real bug fix** — incorrect error propagation. The function
was designed to extract the error number from the server's rejection
message but then threw it away. This could cause:
- Incorrect reconnection behavior (treating `-EBUSY` like `-ECONNRESET`)
- Misleading error reporting to upper layers
- Potentially infinite reconnection loops or incorrect session
  management decisions

### Scope and Risk Assessment

- **Lines changed**: ~3 lines of actual logic change
- **Files touched**: 1
- **Complexity**: Very low
- **Risk**: Very low — the default initialization ensures backward-
  compatible behavior for the malformed-message path, and the fix simply
  propagates information that was already being parsed but discarded
- **Subsystem**: RDMA/rtrs (RDMA Transport) — used for high-performance
  storage over RDMA networks

### Review and Testing

- Has `Reviewed-by:` from two reviewers (Grzegorz Prajsner and Jack
  Wang)
- Merged by Leon Romanovsky (RDMA subsystem maintainer)
- Part of a patch series (patch 10), but this change is self-contained —
  it doesn't depend on other patches in the series

### User Impact

Users of rtrs (RDMA transport for block storage) could experience
incorrect reconnection behavior when the server rejects connections. The
`-EBUSY` case is particularly important — without the proper error code,
the client can't handle "session still exists" rejections appropriately,
potentially leading to connection failures or suboptimal retry behavior.

### Stable Kernel Criteria Check

1. **Obviously correct and tested**: Yes — simple, well-reviewed,
   logical fix
2. **Fixes a real bug**: Yes — incorrect error code propagation
3. **Important issue**: Moderate — affects connection management in RDMA
   storage, could cause reconnection failures
4. **Small and contained**: Yes — 3 lines changed in 1 file
5. **No new features**: Correct — this fixes existing behavior
6. **Applies cleanly**: Likely — the change is simple and localized

### Risk vs Benefit

- **Risk**: Minimal — the default initialization preserves backward
  compatibility, and the fix is straightforward
- **Benefit**: Correct error propagation enables proper connection
  rejection handling, especially for the `-EBUSY` case

The fix is small, surgical, well-reviewed, and fixes a real bug where
error information was being discarded. It meets all stable kernel
criteria.

**YES**

 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 2b397a544cb93..8fa1d72bd20a4 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -1923,7 +1923,7 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con,
 	struct rtrs_path *s = con->c.path;
 	const struct rtrs_msg_conn_rsp *msg;
 	const char *rej_msg;
-	int status, errno;
+	int status, errno = -ECONNRESET;
 	u8 data_len;
 
 	status = ev->status;
@@ -1945,7 +1945,7 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con,
 			  status, rej_msg);
 	}
 
-	return -ECONNRESET;
+	return errno;
 }
 
 void rtrs_clt_close_conns(struct rtrs_clt_path *clt_path, bool wait)
-- 
2.51.0


  parent reply	other threads:[~2026-02-15 15:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-15 15:03 [PATCH AUTOSEL 6.19-6.12] riscv: vector: init vector context with proper vlenb Sasha Levin
2026-02-15 15:03 ` [PATCH AUTOSEL 6.19-6.12] scsi: ufs: mediatek: Fix page faults in ufs_mtk_clk_scale() trace event Sasha Levin
2026-02-15 15:03 ` [PATCH AUTOSEL 6.19-6.1] hisi_acc_vfio_pci: update status after RAS error Sasha Levin
2026-02-15 15:03 ` [PATCH AUTOSEL 6.19-6.18] hisi_acc_vfio_pci: fix the queue parameter anomaly issue Sasha Levin
2026-02-15 15:03 ` [PATCH AUTOSEL 6.19-5.15] scsi: buslogic: Reduce stack usage Sasha Levin
2026-02-15 15:03 ` [PATCH AUTOSEL 6.19-5.15] tracing: Fix false sharing in hwlat get_sample() Sasha Levin
2026-02-15 15:03 ` [PATCH AUTOSEL 6.19-6.6] vhost: fix caching attributes of MMIO regions by setting them explicitly Sasha Levin
2026-02-15 15:03 ` [PATCH AUTOSEL 6.19-6.18] hisi_acc_vfio_pci: resolve duplicate migration states Sasha Levin
2026-02-15 15:03 ` [PATCH AUTOSEL 6.19-6.6] ata: libata: avoid long timeouts on hot-unplugged SATA DAS Sasha Levin
2026-02-15 15:03 ` Sasha Levin [this message]
2026-02-15 15:03 ` [PATCH AUTOSEL 6.19-6.18] um: Preserve errno within signal handler Sasha Levin

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=20260215150333.2150455-10-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=grzegorz.prajsner@ionos.com \
    --cc=haris.iqbal@ionos.com \
    --cc=jinpu.wang@ionos.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /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