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=1796384964; b=wLCvd0qmlZyIwzNdpVEMHzuH8R1rPW9ZUDydaE1y2dN55DRwjzggM4hIg+XDdBunFLCx xemQcxkE9J2IZKiXQXo9pl5yxTHH58B7pGwjqxAijuC6YHgftDwIJVEyhJcmTfFZmFEvD Cbzl8t15XkhsZDvU6vkdJZjUNklKfhgwUDCEoZS2Rtsw0PT7u6ycz+DD/hGKQIPgaQCvf lFyKQyXjEEPxJiQmhoph16LAeP5qEffQ52E6fBNkWNElL4WpISt4H2nVoJ80ap2cZlxBx ZNxCTA5YuCpAT1UvAZnH1Tg0LkxsfeGf5uoKrp14pGxwRDr/RgTh3CrQgnSRT9O+pSQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384964; 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=r41ghLB2VNVGIB5tUF9vl0QcrNwE0eUTAUgRkNhc4PA=; b=VnAJCBbU2m6plrK9+6v6i7cHQCWn++iDo6uiTCTprSezCXtL3gie6tGWVRQaWt1UZvYE PXmaRLkDeP+cN6RD3Z68mFPwuUvr7/54ZlpV7Psgq78TPft4SwDgigaE7qB+J2dRdJxKT yOVME42EcE1kQ5qYOmhjCckzxvbEtIAEMtvx4bbh6O8em48B+hvr0NZkx4c4jziHk13rv hhKdeyUSjwyZ1olSM9pg8DG9AfScu931ZcO1PKjvLCDVcprdeJW2+JgXOf5+yg/6X2DHL cukL9R3C0bGy6r5+zvAOZdoQ+xC4bQZQW3xsn7j0Dg4wfsOyLKDo6P0viPxqdSD5m+A== 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=qZ6uIJuZ; 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 088E7606A32C; Fri, 4 Dec 2026 11:49:24 +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=qZ6uIJuZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BDC31F00933; Fri, 4 Dec 2026 11:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384963; bh=r41ghLB2VNVGIB5tUF9vl0QcrNwE0eUTAUgRkNhc4PA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qZ6uIJuZsdNB0Pzles434hVwiWRWfZOmrfBzy/TApaYV8PlAh6xx+QYH1tuGHlZgc /P70e7KjujK2UfcIJJr38b5u6o61G2jPDGt5X5sbFXRm0heugE+Y8Npe6Z0ZoT22h3 0fvVOfXOI6IDx9HrBXPOp+rr0gW9q29Lfo4v3bb4= 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.6 0363/1167] scsi: scsi_debug: Enforce physical block alignment of zoned writes Date: Fri, 4 Dec 2026 18:56:30 +0900 Message-ID: <20261204100711.437773590@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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: Used mk_sense_buffer() with separate asc/ascq arguments (LBA_OUT_OF_RANGE, UNALIGNED_WRITE_ASCQ) instead of upstream's combined UNALIGNED_WRITE_COMMAND macro, which 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 7e4e119b67250..0d5dce648ff33 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2941,6 +2941,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