From nobody Tue Nov 23 23:12:53 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 156E118A1994; Tue, 23 Nov 2021 23:12:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HzKgB4rSPz3vkH; Tue, 23 Nov 2021 23:12:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 33F371F147; Tue, 23 Nov 2021 23:12:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1ANNCr2B037663; Tue, 23 Nov 2021 23:12:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1ANNCr33037662; Tue, 23 Nov 2021 23:12:53 GMT (envelope-from git) Date: Tue, 23 Nov 2021 23:12:53 GMT Message-Id: <202111232312.1ANNCr33037662@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 412a8b92d9c0 - stable/13 - Further refine the ExpDataSN checks for SCSI Response PDUs. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 412a8b92d9c0490ba700f5ea4f676a16778643bd Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1637709176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sNIHUwHRrT1fdFwQvprt2xfzuVByq/1so2bThIIdH8Y=; b=iv+vGQhUrBNjqB6g0MXXmNil+Y77kpkxKdakksVk3CNLqj/B90BY3uP9zRVaivgwRgf6l+ x3dL3LH2XuaisH+86QoIw1dzkZ3ka69+knaVppgHMcckRVSejbx35bHuPi7J7XFtTe4YuS 6g3jLKueNUYsH03gB5dCOwCtn1ivdv8fHX+MDwbuWUyaWHEfkSv77fXQpeFDFKBk478OGj YUotyedm39yikSLJfce5RV9iWLn+d1HzKXcJ+voAu7MoSEFRS7HbtSl+vIvvoWOrwV9UfK ol8ZYAf/6Vb5K19FxNd/OsKZPwAxX0CLkTe0FgUBHWQYDJbyFgYoKgB2+0uFkg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1637709176; a=rsa-sha256; cv=none; b=pvrcBXBox6Edj69TUGWKb/mdHRFDJXmw+umcTfW7qag1xD8NFXFZrRHgfQUCg31he5PFjp rZdkDGhInKMfwN7oukDooaCgtonKArMdJt4tcodf/XFmyOTklNhw0YBCRAs7iipHORjDyY D1Fvm+4IxjIjNPCRYdJ6cEW9LXptzApSB4OEsAYR8fs7vJxygbudbUshU1aNtlysGUB9a6 BEvcUMj0AoSb14gOjl6h4vy5j3Xp/kePYLxbJRmXj6GhuyTdHz17AbW0YMH2x0iOdS46o5 JFqxF3p1ndVlkHW7n0OAzNeUeQnX2sO1y2DIjCa96JxSb04em3fpII2s+DRgFg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=412a8b92d9c0490ba700f5ea4f676a16778643bd commit 412a8b92d9c0490ba700f5ea4f676a16778643bd Author: John Baldwin AuthorDate: 2021-10-26 21:50:05 +0000 Commit: John Baldwin CommitDate: 2021-11-23 23:11:44 +0000 Further refine the ExpDataSN checks for SCSI Response PDUs. According to 11.4.8 in RFC 7143, ExpDataSN MUST be 0 if the response code is not Command Completed, but we were requiring it to always be the count of DataIn PDUs regardless of the response code. In addition, at least one target (OCI Oracle iSCSI block device) returns an ExpDataSN of 0 when returning a valid completion with an error status (Check Condition) in response to a SCSI Inquiry. As a workaround for this target, only warn without resetting the connection for a 0 ExpDataSN for responses with a non-zero error status. PR: 259152 Reported by: dch Reviewed by: dch, mav, emaste Fixes: 4f0f5bf99591 iscsi: Validate DataSN values in Data-In PDUs in the initiator. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32650 (cherry picked from commit cdbc4a074bec094dc7f1dfde0773a9417d118ffa) --- sys/dev/iscsi/iscsi.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 093ba51d265e..cc860e3f68a8 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -892,15 +892,39 @@ iscsi_pdu_handle_scsi_response(struct icl_pdu *response) } ccb = io->io_ccb; - if (ntohl(bhssr->bhssr_expdatasn) != io->io_datasn) { - ISCSI_SESSION_WARN(is, - "ExpDataSN mismatch in SCSI Response (%u vs %u)", - ntohl(bhssr->bhssr_expdatasn), io->io_datasn); - icl_pdu_free(response); - iscsi_session_reconnect(is); - ISCSI_SESSION_UNLOCK(is); - return; + if (bhssr->bhssr_response == BHSSR_RESPONSE_COMMAND_COMPLETED) { + if (ntohl(bhssr->bhssr_expdatasn) != io->io_datasn) { + ISCSI_SESSION_WARN(is, + "ExpDataSN mismatch in SCSI Response (%u vs %u)", + ntohl(bhssr->bhssr_expdatasn), io->io_datasn); + + /* + * XXX: Permit an ExpDataSN of zero for errors. + * + * This doesn't conform to RFC 7143, but some + * targets seem to do this. + */ + if (bhssr->bhssr_status != 0 && + bhssr->bhssr_expdatasn == htonl(0)) + goto skip_expdatasn; + + icl_pdu_free(response); + iscsi_session_reconnect(is); + ISCSI_SESSION_UNLOCK(is); + return; + } + } else { + if (bhssr->bhssr_expdatasn != htonl(0)) { + ISCSI_SESSION_WARN(is, + "ExpDataSN mismatch in SCSI Response (%u vs 0)", + ntohl(bhssr->bhssr_expdatasn)); + icl_pdu_free(response); + iscsi_session_reconnect(is); + ISCSI_SESSION_UNLOCK(is); + return; + } } +skip_expdatasn: /* * With iSER, after getting good response we can be sure