Page MenuHomeFreeBSD

iscsi: Allocate a dummy PDU for the internal nexus reset task.
ClosedPublic

Authored by jhb on Jan 26 2022, 9:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 8, 10:01 AM
Unknown Object (File)
Sun, Apr 7, 2:53 PM
Unknown Object (File)
Jan 10 2024, 3:35 AM
Unknown Object (File)
Dec 20 2023, 5:04 PM
Unknown Object (File)
Dec 12 2023, 9:34 AM
Unknown Object (File)
Nov 29 2023, 11:37 PM
Unknown Object (File)
Nov 8 2023, 8:06 AM
Unknown Object (File)
Nov 6 2023, 10:33 AM
Subscribers

Details

Summary

When an iSCSI target session is terminated, an internal nexus reset
task is posted to abort existing tasks belonging to the session.
Previously, the ctl_io for this internal nexus reset stored a pointer
to the session in the slot that normally holds a pointer to the PDU
from the initiator that triggered the I/O request. The completion
handler then assumed that any nexus reset I/O was due to an internal
request and fetched the session pointer (instead of the PDU pointer)
from the ctl_io. However, it is possible to trigger a nexus reset via
an on-the-wire task management PDU. If such a PDU were sent to the
target, then the completion handler would incorrectly treat this
request as an internal request and treat the pointer to the received
PDU as a pointer to the session instead.

To fix, allocate a dummy PDU for the internal reset task and use an
invalid opcode to differentiate internal nexus resets from resets
requested by the initiator.

PR: 260449
Reported by: Robert Morris <rtm@lcs.mit.edu>
Sponsored by: Chelsio Communications

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Jan 26 2022, 9:39 PM

I used a patched version of the test program from the PR to test this (patched to not start ctld as I had an existing target machine to run against and changed the IP address and name of the target). It no longer panics but instead reports the following error:

WARNING: 10.1.161.31 (iqn.1994-09.org.freebsd:): received PDU with CmdSN 0, while expected 1
WARNING: 10.1.161.31 (iqn.1994-09.org.freebsd:): connection error; dropping connection

It looks OK to me. I am just thinking: would it be cleaner to use for example ISCSI_BHS_OPCODE_LOGOUT_REQUEST instead, which does not go through cfiscsi_done() now, or it would be more confusing.

This revision is now accepted and ready to land.Jan 27 2022, 2:49 AM
In D34055#770065, @mav wrote:

It looks OK to me. I am just thinking: would it be cleaner to use for example ISCSI_BHS_OPCODE_LOGOUT_REQUEST instead, which does not go through cfiscsi_done() now, or it would be more confusing.

I don't really know. We could reuse an existing target opcode (since we should never get one of those). It's part of why I added a new constant so it's easy to redefine it to something else.