Skip to content

Commit 182a4b7

Browse files
easwarhgregkh
authored andcommitted
scsi: storvsc: Ratelimit warning logs to prevent VM denial of service
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: microsoft/WSL#9173 Signed-off-by: Easwar Hariharan <[email protected]> Link: https://lore.kernel.org/r/20250107-eahariha-ratelimit-storvsc-v1-1-7fc193d1f2b0@linux.microsoft.com Reviewed-by: Michael Kelley <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ce11424 commit 182a4b7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/scsi/storvsc_drv.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ do { \
171171
dev_warn(&(dev)->device, fmt, ##__VA_ARGS__); \
172172
} while (0)
173173

174+
#define storvsc_log_ratelimited(dev, level, fmt, ...) \
175+
do { \
176+
if (do_logging(level)) \
177+
dev_warn_ratelimited(&(dev)->device, fmt, ##__VA_ARGS__); \
178+
} while (0)
179+
174180
struct vmscsi_request {
175181
u16 length;
176182
u8 srb_status;
@@ -1168,7 +1174,7 @@ static void storvsc_on_io_completion(struct storvsc_device *stor_device,
11681174
int loglevel = (stor_pkt->vm_srb.cdb[0] == TEST_UNIT_READY) ?
11691175
STORVSC_LOGGING_WARN : STORVSC_LOGGING_ERROR;
11701176

1171-
storvsc_log(device, loglevel,
1177+
storvsc_log_ratelimited(device, loglevel,
11721178
"tag#%d cmd 0x%x status: scsi 0x%x srb 0x%x hv 0x%x\n",
11731179
scsi_cmd_to_rq(request->cmd)->tag,
11741180
stor_pkt->vm_srb.cdb[0],

0 commit comments

Comments
 (0)