Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751949AbdFHPnn (ORCPT ); Thu, 8 Jun 2017 11:43:43 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:54400 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751642AbdFHPnl (ORCPT ); Thu, 8 Jun 2017 11:43:41 -0400 X-IronPort-AV: E=Sophos;i="5.39,315,1493654400"; d="scan'208";a="24694948" From: Bart Van Assche To: "target-devel@vger.kernel.org" , "nab@linux-iscsi.org" CC: "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "mchristi@redhat.com" , "roland@purestorage.com" , "hare@suse.de" , "martin.petersen@oracle.com" Subject: Re: [PATCH] iscsi-target: Reject immediate data underflow larger than SCSI transfer length Thread-Topic: [PATCH] iscsi-target: Reject immediate data underflow larger than SCSI transfer length Thread-Index: AQHS4A5DNXdpZ4WaCUuW3rpeuY6x8KIbGi6A Date: Thu, 8 Jun 2017 15:37:34 +0000 Message-ID: <1496936253.3028.1.camel@wdc.com> References: <1496895685-18464-1-git-send-email-nab@linux-iscsi.org> In-Reply-To: <1496895685-18464-1-git-send-email-nab@linux-iscsi.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=sandisk.com; x-originating-ip: [63.163.107.100] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY1PR0401MB1533;7:4QKoAJmRlBc4CdQnUyJrhJTEbc5Iz3seyYDJxNO14jztP5hthFZUohY+MgC+8R7KOA9ErEN9gTmlDdjSmYkrd0ClkFnVYmqH8bPi2IaYuwLAvK9y5B+O4TyOo45BZD2NdOBTHHdWpntK7k5pmQiLD+VFQjZC5LhLQrUlzq9p5jhgi/nHpGMxAoyTGyPS1N/I0tdRyJiRtSZsK+MxROI+5+zcCFlxwtXZsuzDw/WYuqiJquEBZuFEuR1yI/mI7t5kLVRFJOGJ/aLxh3J3QH6uQbq1AaDjx6ioBbyPFpeOME8b/s1sxb8sS8yaWroojvd9AkmTKupsth6JLR0vQ9lOQg==;20:XMllldYHx7nEf/6qdM5wckakYTZXhDxa3ZJMMeB726iFNZAD9U6TkLjxdwrye3VGXRb8WpKl0oKpn57nCsliZMFSqqTeQDjmgxfDwCm4J4lqwkKJMBvXuB3b8THbDjJ4Kpn/ktfjqFTG8quFE1Sd5ss30eREW85SR9HBBj6iqCo= x-ms-traffictypediagnostic: CY1PR0401MB1533: x-ms-office365-filtering-correlation-id: b8b2f6b9-8e61-4f4d-20f0-08d4ae84489a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081);SRVR:CY1PR0401MB1533; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123558100)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR0401MB1533;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR0401MB1533; x-forefront-prvs: 0332AACBC3 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(39840400002)(39450400003)(39410400002)(39850400002)(39400400002)(24454002)(377424004)(50986999)(189998001)(7736002)(36756003)(76176999)(305945005)(5660300001)(72206003)(103116003)(54356999)(478600001)(14454004)(33646002)(217423001)(122556002)(81166006)(8936002)(2501003)(8676002)(4326008)(102836003)(3846002)(3660700001)(99286003)(53936002)(3280700002)(9686003)(6512007)(2950100002)(6306002)(229853002)(6506006)(6436002)(25786009)(6486002)(2906002)(38730400002)(86362001)(2900100001)(66066001)(54906002)(77096006)(6246003)(14773001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0401MB1533;H:CY1PR0401MB1536.namprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-ID: <88F4A4B7C39F01419B37EEBC690F3AF2@namprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jun 2017 15:37:34.1809 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0401MB1533 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v58FhlHi004030 Content-Length: 1162 Lines: 27 On Thu, 2017-06-08 at 04:21 +0000, Nicholas A. Bellinger wrote: > + /* > + * Check for underflow case where both EDTL and immediate data payload > + * exceeds what is presented by CDB's TRANSFER LENGTH, and what has > + * already been set in target_cmd_size_check() as se_cmd->data_length. > + * > + * For this special case, fail the command and dump the immediate data > + * payload. > + */ > + if (cmd->first_burst_len > cmd->se_cmd.data_length) { > + cmd->sense_reason = TCM_INVALID_CDB_FIELD; > + goto after_immediate_data; > + } A quote from the iSCSI RFC (https://tools.ietf.org/html/rfc5048): If SPDTL < EDTL for a task, iSCSI Underflow MUST be signaled in the ???SCSI Response PDU as specified in [RFC3720].??The Residual Count MUST ???be set to the numerical value of (EDTL - SPDTL). Sorry but I don't think that sending TCM_INVALID_CDB_FIELD back to the initiator is compliant with the iSCSI RFC. Please note that a fix that is compliant with the iSCSI RFC is present in the following patch series: [PATCH 00/33] SCSI target driver patches for kernel v4.13, 23 May 2017 (https://www.spinics.net/lists/target-devel/msg15370.html). Bart.