Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 0/2] scsi: target: iscsi: Fix adding a connection to a session that is going away
@ 2026-11-27 13:52 Rongen Wang via B4 Relay
  2026-11-27 13:52 ` [PATCH v2 1/2] scsi: target: iscsi: Refuse to add a connection to a session being closed Rongen Wang via B4 Relay
  2026-11-27 13:52 ` [PATCH v2 2/2] scsi: target: iscsi: Do not let Time2Retain expire a session in use Rongen Wang via B4 Relay
  0 siblings, 2 replies; 4+ messages in thread
From: Rongen Wang via B4 Relay @ 2026-11-27 13:52 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: linux-scsi, target-devel, stable, Rongen Wang

A Login Request with a non-zero TSIH can complete after the session it
joins has lost its last connection. Patch 1 makes
iscsi_post_login_handler() refuse such a login when the session is
being closed or its Time2Retain timer has expired. Patch 2 keeps the
Time2Retain handler from expiring a session while such a login holds
it; without patch 2 the session that patch 1 refuses to join is never
freed.

Based on mkp/scsi.git 7.4/scsi-fixes (4be084ac36f9). Patch 2 changes
iscsit_time2retain_work() from b30d7199af28 ("scsi: target: iscsi: Run
the Time2Retain handler in process context"), which is in that tree and
marked for stable. Patch 1 also applies to mainline 9437ee8b6cf6.

Tested on that tree under QEMU, iSCSI/TCP, with KASAN and again with
KASAN plus PROVE_LOCKING, DEBUG_ATOMIC_SLEEP and DEBUG_OBJECTS_TIMERS /
DEBUG_OBJECTS_WORK:

- Last connection reset while a TSIH != 0 login is parked (the v1
  case): the login is refused, no report.
- DefaultTime2Retain=2, last connection logged out with CLOSE_CONNECTION
  while a TSIH != 0 login is parked, login finished after the timer ran
  out: the login continues the session, I/O works, and the session is
  freed when that connection is reset or logs out. Without the series,
  and with v1, the connection joins the half closed session and its
  logout gives the KASAN report quoted in patch 1. With patch 1 alone
  the login is refused and the session stays allocated.
- The same with DefaultTime2Retain=1 and the final Login PDU sent
  0.6 s to 1.4 s after the logout, 40 rounds: every login continues its
  session, no session is left allocated, no report. With v1, 14 of the
  16 rounds that ran into the expiry gave KASAN reports; with patch 1
  alone 17 sessions were left allocated.
- MaxConnections=2: adding a connection to a live session, I/O on both,
  logouts, a fresh login, and session continuation after a
  CLOSE_CONNECTION logout still work.
- NodeACL removed while a TSIH != 0 login is parked: no report.

The refusal path in __iscsi_target_login_thread() (login completed by
its first PDU) was not reached by these tests; iSER and cxgbit were not
tested. No W=1 warnings in drivers/target/iscsi/, checkpatch clean.

Reproducers for both cases go to the maintainer privately and are not
posted here.

---
Changes in v2:
- Patch 1: also refuse the login when the Time2Retain timer has
  expired, check under se_tpg->session_lock and sess->conn_lock like
  the session lookups do, and stop the timer before session_lock is
  dropped (Sashiko review)
- Patch 1: take over the session parameters and release
  conn->param_list only after the check (Sashiko review)
- New patch 2: do not let Time2Retain expire a session while a login
  holds a usage count
- Sashiko review of v1: https://sashiko.dev/#/patchset/20261127-b4-lio-iscsi-session-closing-v1-1-cdf2bbbef87a@nitrohex.com
- Link to v1: https://patch.msgid.link/20261127-b4-lio-iscsi-session-closing-v1-1-cdf2bbbef87a@nitrohex.com

---
Rongen Wang (2):
      scsi: target: iscsi: Refuse to add a connection to a session being closed
      scsi: target: iscsi: Do not let Time2Retain expire a session in use

 drivers/target/iscsi/iscsi_target_erl0.c  |  21 ++++++
 drivers/target/iscsi/iscsi_target_login.c | 117 ++++++++++++++++++++++++------
 drivers/target/iscsi/iscsi_target_login.h |   4 +-
 drivers/target/iscsi/iscsi_target_nego.c  |   5 +-
 4 files changed, 121 insertions(+), 26 deletions(-)
---
base-commit: 4be084ac36f95f95e21a1e39207e87326967a73d
change-id: 20261127-b4-lio-iscsi-session-closing-67f4557094ce

Best regards,
--  
Rongen Wang <security@nitrohex.com>



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-27 14:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 13:52 [PATCH v2 0/2] scsi: target: iscsi: Fix adding a connection to a session that is going away Rongen Wang via B4 Relay
2026-11-27 13:52 ` [PATCH v2 1/2] scsi: target: iscsi: Refuse to add a connection to a session being closed Rongen Wang via B4 Relay
2026-11-27 13:52 ` [PATCH v2 2/2] scsi: target: iscsi: Do not let Time2Retain expire a session in use Rongen Wang via B4 Relay
2026-11-27 14:07   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox