Skip to contentSkip to conversation

scsi: storvsc: Ratelimit warning logs to prevent VM denial of service

PATCH In review Easwar Hariharan 3 participants 5 messages Jan 27, 2025 – Jan 28, 2025 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/scsi/storvsc_drv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/scsi/storvsc_drv.c +7 -1
index d0b55c1fa908..b3c588b102d9 100644
@@ -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(struct storvsc_device *stor_device,
 		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],
Signature · 1 line
2.43.0
#1 lore raw
Quoted 13 lines · 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.

Quoted 4 lines
---
 drivers/scsi/storvsc_drv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

I just remembered that we should wait for Linus to tag the rc before sending backports, so apologies for sending this (and its 6.1 and 6.12 friends) out before rc1 was tagged.

- Easwar (he/him)

maintainer
#2 lore raw
Quoted 19 lines · Easwar Hariharan
Quoted 13 lines · 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.

Quoted 4 lines
---
 drivers/scsi/storvsc_drv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Quoted 3 lines

I just remembered that we should wait for Linus to tag the rc before sending backports, so apologies for sending this (and its 6.1 and 6.12 friends) out before rc1 was tagged.

Why was this not tagged for stable in the first place?

thanks,

greg k-h

#3 lore raw
Quoted 24 lines · Greg KH
Quoted 19 lines · Easwar Hariharan
Quoted 13 lines · 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.

Quoted 4 lines
---
 drivers/scsi/storvsc_drv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Quoted 3 lines

I just remembered that we should wait for Linus to tag the rc before sending backports, so apologies for sending this (and its 6.1 and 6.12 friends) out before rc1 was tagged.

Quoted 5 lines

Why was this not tagged for stable in the first place?

thanks,

greg k-h

An oversight when I sent the original patch.

- Easwar (he/him)

maintainer Reviewed-by Michael Kelley on v1 1/1
#4 lore raw
In reply to Easwar Hariharan

[ Sasha's backport helper bot ]

Hi,

The upstream commit SHA1 provided is correct: d2138eab8cde61e0e6f62d0713e45202e8457d6d

Status in newer kernel trees:
6.13.y | Branch not found
6.12.y | Not found
6.6.y | Not found

Note: The patch differs from the upstream commit:
---
1: d2138eab8cde6 ! 1: eff28b745a790 scsi: storvsc: Ratelimit warning logs to prevent VM denial of service
@@ Metadata
## Commit message ##
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
@@ Commit message

+ Signed-off-by: Easwar Hariharan <[email protected]>

## drivers/scsi/storvsc_drv.c ##
@@ drivers/scsi/storvsc_drv.c: do { \
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.6.y        |  Success    |  Success   |