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 4C09F1DDE9; Thu, 30 Jan 2025 14:15:57 +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=1738246557; cv=none; b=re8m/ROcDseYh2r1eg1fEw9pY1ugGqSWezCiDCZv2yKrLG8WFOMMTGc6Ik6IRCWpuA6XzCCX4Qm8eq7FFTEXAgbRv2gKBYx22S+PnFTv29peDJG6U5mRvMtPD2GjcmZtJX6wD/sJSkSBcrV1e2GaQbM2YDuYeokyoGMzsivdmYo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246557; c=relaxed/simple; bh=ZHz1dK8HMoaOOFhYbBoEHfqEPfEMIYm6JqKSh4m2jHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=odqPtijzHRuy2EVpBY13QxzIpTGciloibKoUF5AvJ5YWYy3hsOtHBhMC+mcFhP7axkaU2kiVjbOo28iKU0JVCMzI3K45pgHfVQo1vtMxmzr/yZ+Ttawnm2bSVDe+c/U9j8QTViIbwsTQVXNvdV7vv9yEAYxJqgIvvtwmF4QtXBg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HsKam5R4; 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="HsKam5R4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCD47C4CED2; Thu, 30 Jan 2025 14:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738246557; bh=ZHz1dK8HMoaOOFhYbBoEHfqEPfEMIYm6JqKSh4m2jHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HsKam5R4JhcT2W29CJ+HLyW3i5DxqELNcHgAaMZz9zmr5xgis6cccttzff/35ZJax Ck081uSVLZ11YOVfrJzu8nCrW+nhciFpl/TF/d+1uvXcRomSYFhsTVnJ5O8OTFfNFA iQ1t0ECsQhfZ+HJSsZJ6cQd6S5YpoHp9taZQjfZw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Easwar Hariharan , Michael Kelley , "Martin K. Petersen" Subject: [PATCH 6.6 33/43] scsi: storvsc: Ratelimit warning logs to prevent VM denial of service Date: Thu, 30 Jan 2025 14:59:40 +0100 Message-ID: <20250130133500.234798683@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130133458.903274626@linuxfoundation.org> References: <20250130133458.903274626@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Easwar Hariharan commit d2138eab8cde61e0e6f62d0713e45202e8457d6d upstream. If there's a persistent error in the hypervisor, the SCSI warning for failed I/O can flood the kernel log and max out CPU utilization, preventing troubleshooting from the VM side. Ratelimit the warning so it doesn't DoS the VM. Closes: https://github.com/microsoft/WSL/issues/9173 Signed-off-by: Easwar Hariharan Link: https://lore.kernel.org/r/20250107-eahariha-ratelimit-storvsc-v1-1-7fc193d1f2b0@linux.microsoft.com Reviewed-by: Michael Kelley Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/storvsc_drv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -171,6 +171,12 @@ do { \ dev_warn(&(dev)->device, fmt, ##__VA_ARGS__); \ } while (0) +#define storvsc_log_ratelimited(dev, level, fmt, ...) \ +do { \ + if (do_logging(level)) \ + dev_warn_ratelimited(&(dev)->device, fmt, ##__VA_ARGS__); \ +} while (0) + struct vmscsi_request { u16 length; u8 srb_status; @@ -1177,7 +1183,7 @@ static void storvsc_on_io_completion(str int loglevel = (stor_pkt->vm_srb.cdb[0] == TEST_UNIT_READY) ? STORVSC_LOGGING_WARN : STORVSC_LOGGING_ERROR; - storvsc_log(device, loglevel, + storvsc_log_ratelimited(device, loglevel, "tag#%d cmd 0x%x status: scsi 0x%x srb 0x%x hv 0x%x\n", scsi_cmd_to_rq(request->cmd)->tag, stor_pkt->vm_srb.cdb[0],