From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382726; b=05+kUESqM0QDm6Q8bDZu0C3IO+dZrGBaqAvKO5qv56ROQ+IdrQCpyLcwoEL/7UHdSYtg 7PfK7KmSFobtIikekIFN1B7EqZVwTKXkrKQOrL5OsXLb2PXbx7QUUxLMZysCdHTqNPj2h hmMseS7x5uZ/aNMZInZR+s9fm8BRsCp/OmZ5z/1Fm9s4lu8eLGn7i0iyOd8wIr/yjEjZ9 +YzO0QGV//1KaZYorR0Rz2sgi78RYWKLrgoYYHVTJec7vpQCE2j6Xi8LBs1/wiJEH6wGj sFfF8MlcOVZUTxEyPM6jRgQ4IhecmV9byxNZt7nRy5wJLNpkGVNy0hcGEmn2/GUhmIg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382726; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=w3yLCgL4h8//+/hTUcy6rvRBLMsCQ/G54RSh6jYCols=; b=TELFt8+GubwL3dAD1hw/7/3IqPO0HNv9SNBgCDrSoZGq+NEYVLUWk7gGq0YSk7VthfQv oFmWCxGISHA5nkBamPZRcpMIsCUx8AXhMxT2tvZJ35M7PeaIk8qv/dHProo2lvNoWLedf Dfl2YDHVJOtYZ82QQE81/fY/2pF4ner/1V/fYvZOCObbGCawUJryVjRK6GdautGufi8br utDY5W26eqRFgFqUqIaazqkcV26bA4M/mSKGOcsTK78E57xZ9e9HIBRvlIulUOjhLmNSJ qLGsXO81IPUnI6zwKNCc58K5Uu3VZYU8AFiAyyCUv/3hiyLHmAJQUHwkRUH0ccSR4aA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=gRrlYuTP; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5F49606A6A1; Fri, 4 Dec 2026 11:12:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=gRrlYuTP Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A5BD1F00A17; Fri, 4 Dec 2026 11:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382726; bh=w3yLCgL4h8//+/hTUcy6rvRBLMsCQ/G54RSh6jYCols=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gRrlYuTPqmNju5WtHRQsmL+45V/bIPCRA+oxgfamVXC2sGC7CGRBbfWtZluv8Z1JY 0NjCyEfTeqc1f8Unl2OHOe4dm2Xy9h3L4MMmIzfksuZYDqE0Pv+Jdmzy5ue9rH0HFT hxlUoH6oIGVp+VMAd2UbGva837XGSrDYuGc1IaKQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Praneeth Balasubramanian , "Martin K. Petersen (Oracle)" Subject: [PATCH 6.18 577/703] scsi: target: iscsi: Check for existing sessions only after authentication Date: Fri, 4 Dec 2026 19:07:56 +0900 Message-ID: <20261204100643.110151313@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Praneeth Balasubramanian commit 48d3b732e5ad3fffe74e033d9a3cf47ebaa314b0 upstream. In the operational-negotiation path (CSG=1), iscsi_target_handle_csg_one() calls iscsi_target_check_for_existing_instances() before iscsi_conn_authenticated(). An initiator can therefore send a first Login PDU with CSG=1, TSIH=0 and no CHAP exchange, carrying the InitiatorName and ISID of an existing session. The target reinstates that session, which tears down the legitimate initiator's connection. Only afterwards does it reject the login with AUTH_FAILED. iscsi_check_for_session_reinstatement() matches on ISID, InitiatorName and SessionType only. The InitiatorName is not secret, and open-iscsi ISIDs are a fixed OUI followed by a small session counter. A remote peer with no credentials can thus repeatedly disconnect a CHAP-authenticated session and keep its I/O failing. The comment above iscsi_target_check_for_existing_instances() already states the intended invariant: NOTE: We check for existing sessions or connections AFTER the initiator has been successfully authenticated in order to protect against faked ISID/TSIH combinations. The security-negotiation path (CSG=0) honours this, calling the check only once authentication completes. Move the CSG=1 call below the authentication check so both paths behave the same. When authentication is not required, iscsi_conn_authenticated() returns true and behaviour is unchanged. Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian Link: https://patch.msgid.link/20261029205456.1211532-1-praneethb2002@gmail.com Signed-off-by: Martin K. Petersen (Oracle) Signed-off-by: Greg Kroah-Hartman --- drivers/target/iscsi/iscsi_target_nego.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c @@ -982,9 +982,6 @@ static int iscsi_target_handle_csg_one(s if (iscsi_target_check_first_request(conn, login) < 0) return -1; - if (iscsi_target_check_for_existing_instances(conn, login) < 0) - return -1; - ret = iscsi_encode_text_output( PHASE_OPERATIONAL|PHASE_DECLARATIVE, SENDER_TARGET, @@ -1008,6 +1005,9 @@ static int iscsi_target_handle_csg_one(s return -1; } + if (iscsi_target_check_for_existing_instances(conn, login) < 0) + return -1; + if (!iscsi_check_negotiated_keys(conn->param_list)) if ((login_req->flags & ISCSI_FLAG_LOGIN_NEXT_STAGE3) && (login_req->flags & ISCSI_FLAG_LOGIN_TRANSIT))