From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B2B31D63E8; Wed, 19 Feb 2025 09:24:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739957058; cv=none; b=DYZ/zjjPb3/y/mOwHxWD+Vca+lalNW5uA6Y4pb9a3lRdhwm3EPUiYPwVJqVYp/5SgkZRLha0NtxjSfu5TdkG8InwAjfl+R7muuHEflluUNPLLkQdMVNteKdGOzt2RUKY2pcH4/LTzyDd5dHP5nAlZsi3WHJHtgn8NxHNcHw4oT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739957058; c=relaxed/simple; bh=6EIp7Yw1DnwR7f0+C1XTBFewQUp1WrZ0W0n73WJ7IUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dt5ZO3cCCg4NINTcFU9yzTqksLuCqVoERnLvlnvZKhhftg3Gb67smmpzgE8wVu76iqH8zXZWQDsmkpqj11Jpj9LJbaRnkCKWJRgE8vYmrWQuuKJGNxbMLOJ/dZ00mtHny3GcSM6oXoRKIhzbfH18zpP2Kj7N2W7KWoNfOOJEEok= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yN9BkXeu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="yN9BkXeu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B67E7C4CEE7; Wed, 19 Feb 2025 09:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1739957058; bh=6EIp7Yw1DnwR7f0+C1XTBFewQUp1WrZ0W0n73WJ7IUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yN9BkXeuySg010QBtvxTT0fCu0coHFEOO3S2s3uGk2PFX2E+7UTLmzS9maHS+A7vL qZg5Rl80p8ipFb519giG25jbfYlUjtbS5aX+y1RovG2CxEXTu6QQr/OfrD8vkC6+jq RBnEI2k+L/DmGKankbVG9MMt//2Hn1SQWgnBu0ds= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Roman Kisel , Michael Kelley , Long Li , "Martin K. Petersen" Subject: [PATCH 6.1 394/578] scsi: storvsc: Set correct data length for sending SCSI command without payload Date: Wed, 19 Feb 2025 09:26:38 +0100 Message-ID: <20250219082708.525432164@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250219082652.891560343@linuxfoundation.org> References: <20250219082652.891560343@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Long Li commit 87c4b5e8a6b65189abd9ea5010ab308941f964a4 upstream. In StorVSC, payload->range.len is used to indicate if this SCSI command carries payload. This data is allocated as part of the private driver data by the upper layer and may get passed to lower driver uninitialized. For example, the SCSI error handling mid layer may send TEST_UNIT_READY or REQUEST_SENSE while reusing the buffer from a failed command. The private data section may have stale data from the previous command. If the SCSI command doesn't carry payload, the driver may use this value as is for communicating with host, resulting in possible corruption. Fix this by always initializing this value. Fixes: be0cf6ca301c ("scsi: storvsc: Set the tablesize based on the information given by the host") Cc: stable@kernel.org Tested-by: Roman Kisel Reviewed-by: Roman Kisel Reviewed-by: Michael Kelley Signed-off-by: Long Li Link: https://lore.kernel.org/r/1737601642-7759-1-git-send-email-longli@linuxonhyperv.com Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/storvsc_drv.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1791,6 +1791,7 @@ static int storvsc_queuecommand(struct S length = scsi_bufflen(scmnd); payload = (struct vmbus_packet_mpb_array *)&cmd_request->mpb; + payload->range.len = 0; payload_sz = 0; if (scsi_sg_count(scmnd)) {