]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg/IScsiDxe: re-set session-level authentication state before login
authorLaszlo Ersek <lersek@redhat.com>
Tue, 29 Jun 2021 16:33:32 +0000 (18:33 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 30 Jun 2021 19:20:41 +0000 (19:20 +0000)
RFC 7143 explains that a single iSCSI session may use multiple TCP
connections. The first connection established is called the leading
connection. The login performed on the leading connection is called the
leading login. Before the session is considered full-featured, the leading
login must succeed. Further (non-leading) connections can be associated
with the session later.

(It's unclear to me from RFC 7143 whether the non-leading connections
require individual (non-leading) logins as well, but that particular
question is irrelevant from the perspective of this patch; see below.)

The data model in IScsiDxe exhibits some confusion, regarding connection /
session association:

- On one hand, the "ISCSI_SESSION.Conns" field is a *set* (it has type
  LIST_ENTRY), and accordingly, connections can be added to, and removed
  from, a session, with the IScsiAttatchConnection() and
  IScsiDetatchConnection() functions.

- On the other hand, ISCSI_MAX_CONNS_PER_SESSION has value 1, therefore no
  session will ever use more than 1 connection at a time (refer to
  instances of "Session->MaxConnections" in
  "NetworkPkg/IScsiDxe/IScsiProto.c").

This one-to-many confusion between ISCSI_SESSION and ISCSI_CONNECTION is
very visible in the CHAP logic, where the progress of the authentication
is maintained *per connection*, in the "ISCSI_CONNECTION.AuthStep" field
(with values such as ISCSI_AUTH_INITIAL, ISCSI_CHAP_STEP_ONE, etc), but
the *data* for the authentication are maintained *per session*, in the
"AuthType" and "AuthData" fields of ISCSI_SESSION. Clearly, this makes no
sense if multiple connections are eligible for logging in.

Knowing that IScsiDxe uses only one connection per session (put
differently: knowing that any connection is a leading connection, and any
login is a leading login), there is no functionality bug. But the data
model is still broken: "AuthType", "AuthData", and "AuthStep" should be
maintained at the *same* level -- be it "session-level" or "(leading)
connection-level".

Fixing this data model bug is more than what I'm signing up for. However,
I do need to add one function, in preparation for multi-hash support:
whenever a new login is attempted (put differently: whenever the leading
login is re-attempted), which always happens with a fresh connection, the
session-level authentication data needs to be rewound to a sane initial
state.

Introduce the IScsiSessionResetAuthData() function. Call it from the
central -- session-level -- IScsiSessionLogin() function, just before the
latter calls the -- connection-level -- IScsiConnLogin() function.

Right now, do nothing in IScsiSessionResetAuthData(); so functionally
speaking, the patch is a no-op.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3355
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210629163337.14120-2-lersek@redhat.com>

NetworkPkg/IScsiDxe/IScsiProto.c

index 6983f0fa5973feb4aa84f4f516cecd616e4a34fc..69d1b39dbb1f9f30927cbdfbc6b49c6b7a090de5 100644 (file)
@@ -417,6 +417,23 @@ ON_EXIT:
   return Status;\r
 }\r
 \r
+/**\r
+  Re-set any stateful session-level authentication information that is used by\r
+  the leading login / leading connection.\r
+\r
+  (Note that this driver only supports a single connection per session -- see\r
+  ISCSI_MAX_CONNS_PER_SESSION.)\r
+\r
+  @param[in,out] Session  The iSCSI session.\r
+**/\r
+STATIC\r
+VOID\r
+IScsiSessionResetAuthData (\r
+  IN OUT ISCSI_SESSION *Session\r
+  )\r
+{\r
+}\r
+\r
 /**\r
   Login the iSCSI session.\r
 \r
@@ -470,6 +487,7 @@ IScsiSessionLogin (
     //\r
     // Login through the newly created connection.\r
     //\r
+    IScsiSessionResetAuthData (Session);\r
     Status = IScsiConnLogin (Conn, Session->ConfigData->SessionConfigData.ConnectTimeout);\r
     if (EFI_ERROR (Status)) {\r
       IScsiConnReset (Conn);\r