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=1796387636; b=fjbDEzfDnqIhyt7v93imP2gkq+faMTo4Oevwz78uXNSzbnHVhz5qrh9IL2/pGDPU6qAZ 8ImqPIIjPQGKx2+HjDUSGwHb9j5sQ00nxcg+rZiwx5PrkgyG4OOQqAbe8DTPF4el8dU2z 0ytqHgoQtE+5D/o8mhAPV9oBukFJIa40x0kBBntQyki+z6fwKI3Sdz2s77RzeeWAYWsjp snNBGEJAHTGrZOyeR9yAl+DIlhe479Ld54QOnlZ3rQEc7y6E0AdPdiyIzJwusl7J5BmCH 0qwi3Mh7lzjy3mEbzB/s5dUghuFmCgKAoqMtyeTSAufg65UO08GQO5qzSMEOivEIkEw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387636; 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=1Lg8nEPjBSqvspWqcdUht1trteje0WYGtKcpcLJozzg=; b=UvsLnHJ5GFaPmiA2Ejcar8+Tu74/ofz4NqQ2Z1W3QRpE5LVrSzrfghnXeADqmxa/+zo+ RbW7iMv5OpL4aQ0uH87ROUEecsivS1pK3iZP1pXmmq/ENKOGwho41SgRK2JNNNzgCYs7U EJRe4da88x0EVuzhEfDS+aqR5l4g99jUwtWJ53oPAJiRSdcBTp5rheEoLeFuSb1HNA7JN fhYMGYBIhHrcdwz/4iY10fF4Gb7x/IILq1Hth6n/WleKc2fHGMPGJlTmZO0zp6ATzk5OZ lNuerSo+8yy6R2IaEIz3r2wZd2gdGUgXqLgG/zdUnfcgIKeXsE4v6mGDER5eG0dPJCA== 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=zUhwfd0I; 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 D9BFC606A335; Fri, 4 Dec 2026 12:33:56 +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=zUhwfd0I Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBDF61F00931; Fri, 4 Dec 2026 12:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387636; bh=1Lg8nEPjBSqvspWqcdUht1trteje0WYGtKcpcLJozzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zUhwfd0I8WWi4kS8DmqYe/+XgYHvrd9BUcUThaXk0hKAWhWSepA6VXHWjA5wp4cAE CtVRnMXYOmTAkWqOSV/6nkqdv7Iiv+kEt+h1edKzY7MnK4OBms0LGsCPJxd3gNaX4t W4+6H52/nAPQCBsyjIzafT31Ne+AbnSnXAQYLJyw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Damien Le Moal , Niklas Cassel , "Martin K. Petersen (Oracle)" , Sasha Levin Subject: [PATCH 6.1 0328/1059] scsi: scsi_debug: Enforce physical block alignment of zoned writes Date: Fri, 4 Dec 2026 18:57:39 +0900 Message-ID: <20261204100652.763679763@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Niklas Cassel [ Upstream commit 63cb3900be261fccc05cadcf3402058418a5fada ] ZBC-3 r06 (T10/BSR INCITS 579), 4.5.3.3.2, requires a write to a sequential write required zone to be terminated with ILLEGAL REQUEST / UNALIGNED WRITE COMMAND both when it does not start at the write pointer and when it does not end on a physical block boundary. That is why sd_zbc_read_zones() sets the zone_write_granularity queue limit to the physical block size of a host-managed device. check_zbc_access_params() implements the first condition but not the second. So with zbc=managed sector_size=512 physblk_exp=3, a write of a single logical block at the write pointer is accepted and advances the write pointer by one logical block, leaving it off the granularity that was advertised: nothing can write at it any more, and the zone can only be used again after being reset. Check the ending LBA as well, with the same sense data, as the standard gives both conditions the same. An entire medium write same command, which the standard excludes, needs no special case: the preceding check already terminates it with WRITE BOUNDARY VIOLATION. Sequential write preferred zones are left alone, as writes to them need not be sequential, and with the default physblk_exp=0 the check is a no-op. Assisted-by: LLM Fixes: f0d1cf9378bd ("scsi: scsi_debug: Add ZBC zone commands") Reviewed-by: Damien Le Moal Signed-off-by: Niklas Cassel Link: https://patch.msgid.link/20260929082456.857423-23-cassel@kernel.org Signed-off-by: Martin K. Petersen (Oracle) [ sashal: Replaced the two-argument mk_sense_buffer(scp, ILLEGAL_REQUEST, UNALIGNED_WRITE_COMMAND) with the older three-argument form using LBA_OUT_OF_RANGE and UNALIGNED_WRITE_ASCQ, since the combined macro doesn't exist here. ] Signed-off-by: Sasha Levin --- drivers/scsi/scsi_debug.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index edf9a027d70c8..6a9a591c5dd3a 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2953,6 +2953,17 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, UNALIGNED_WRITE_ASCQ); return check_condition_result; } + /* + * Writes must end on a physical block boundary, that is, the + * transfer length must be a multiple of the physical block + * size. + */ + if (!IS_ALIGNED(lba + num, 1U << sdebug_physblk_exp)) { + mk_sense_buffer(scp, ILLEGAL_REQUEST, + LBA_OUT_OF_RANGE, + UNALIGNED_WRITE_ASCQ); + return check_condition_result; + } } /* Handle implicit open of closed and empty zones */ -- 2.53.0