* [PATCH AUTOSEL 6.12 1/4] scsi: storvsc: Ratelimit warning logs to prevent VM denial of service
@ 2025-01-29 12:57 Sasha Levin
2025-01-29 12:57 ` [PATCH AUTOSEL 6.12 2/4] scsi: ufs: bsg: Set bsg_queue to NULL after removal Sasha Levin
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sasha Levin @ 2025-01-29 12:57 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Easwar Hariharan, Michael Kelley, Martin K . Petersen,
Sasha Levin, kys, haiyangz, wei.liu, decui, James.Bottomley,
linux-hyperv, linux-scsi
From: Easwar Hariharan <eahariha@linux.microsoft.com>
[ Upstream commit d2138eab8cde61e0e6f62d0713e45202e8457d6d ]
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 <eahariha@linux.microsoft.com>
Link: https://lore.kernel.org/r/20250107-eahariha-ratelimit-storvsc-v1-1-7fc193d1f2b0@linux.microsoft.com
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/storvsc_drv.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index d0b55c1fa908a..b3c588b102d90 100644
--- 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(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],
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 6.12 2/4] scsi: ufs: bsg: Set bsg_queue to NULL after removal
2025-01-29 12:57 [PATCH AUTOSEL 6.12 1/4] scsi: storvsc: Ratelimit warning logs to prevent VM denial of service Sasha Levin
@ 2025-01-29 12:57 ` Sasha Levin
2025-01-29 12:57 ` [PATCH AUTOSEL 6.12 3/4] rtla/timerlat_hist: Abort event processing on second signal Sasha Levin
2025-01-29 12:57 ` [PATCH AUTOSEL 6.12 4/4] rtla/timerlat_top: " Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-01-29 12:57 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Guixin Liu, Avri Altman, Martin K . Petersen, Sasha Levin,
James.Bottomley, quic_cang, hare, quic_ziqichen, linux-scsi
From: Guixin Liu <kanie@linux.alibaba.com>
[ Upstream commit 1e95c798d8a7f70965f0f88d4657b682ff0ec75f ]
Currently, this does not cause any issues, but I believe it is necessary to
set bsg_queue to NULL after removing it to prevent potential use-after-free
(UAF) access.
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Link: https://lore.kernel.org/r/20241218014214.64533-3-kanie@linux.alibaba.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ufs/core/ufs_bsg.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/ufs/core/ufs_bsg.c b/drivers/ufs/core/ufs_bsg.c
index 6c09d97ae0065..08579c454a325 100644
--- a/drivers/ufs/core/ufs_bsg.c
+++ b/drivers/ufs/core/ufs_bsg.c
@@ -216,6 +216,7 @@ void ufs_bsg_remove(struct ufs_hba *hba)
return;
bsg_remove_queue(hba->bsg_queue);
+ hba->bsg_queue = NULL;
device_del(bsg_dev);
put_device(bsg_dev);
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 6.12 3/4] rtla/timerlat_hist: Abort event processing on second signal
2025-01-29 12:57 [PATCH AUTOSEL 6.12 1/4] scsi: storvsc: Ratelimit warning logs to prevent VM denial of service Sasha Levin
2025-01-29 12:57 ` [PATCH AUTOSEL 6.12 2/4] scsi: ufs: bsg: Set bsg_queue to NULL after removal Sasha Levin
@ 2025-01-29 12:57 ` Sasha Levin
2025-01-29 12:57 ` [PATCH AUTOSEL 6.12 4/4] rtla/timerlat_top: " Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-01-29 12:57 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Tomas Glozar, John Kacur, Luis Goncalves, Gabriele Monaco,
Steven Rostedt, Sasha Levin, bristot, costa.shul,
linux-trace-kernel
From: Tomas Glozar <tglozar@redhat.com>
[ Upstream commit d6899e560366e10141189697502bc5521940c588 ]
If either SIGINT is received twice, or after a SIGALRM (that is, after
timerlat was supposed to stop), abort processing events currently left
in the tracefs buffer and exit immediately.
This allows the user to exit rtla without waiting for processing all
events, should that take longer than wanted, at the cost of not
processing all samples.
Cc: John Kacur <jkacur@redhat.com>
Cc: Luis Goncalves <lgoncalv@redhat.com>
Cc: Gabriele Monaco <gmonaco@redhat.com>
Link: https://lore.kernel.org/20250116144931.649593-5-tglozar@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/tracing/rtla/src/timerlat_hist.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 2cc3ffcbc983d..8dc33e1e6aed2 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -1139,6 +1139,14 @@ static struct osnoise_tool
static int stop_tracing;
static void stop_hist(int sig)
{
+ if (stop_tracing) {
+ /*
+ * Stop requested twice in a row; abort event processing and
+ * exit immediately
+ */
+ tracefs_iterate_stop(hist_inst->inst);
+ return;
+ }
stop_tracing = 1;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 6.12 4/4] rtla/timerlat_top: Abort event processing on second signal
2025-01-29 12:57 [PATCH AUTOSEL 6.12 1/4] scsi: storvsc: Ratelimit warning logs to prevent VM denial of service Sasha Levin
2025-01-29 12:57 ` [PATCH AUTOSEL 6.12 2/4] scsi: ufs: bsg: Set bsg_queue to NULL after removal Sasha Levin
2025-01-29 12:57 ` [PATCH AUTOSEL 6.12 3/4] rtla/timerlat_hist: Abort event processing on second signal Sasha Levin
@ 2025-01-29 12:57 ` Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-01-29 12:57 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Tomas Glozar, John Kacur, Luis Goncalves, Gabriele Monaco,
Steven Rostedt, Sasha Levin, bristot, ezulian, costa.shul,
linux-trace-kernel
From: Tomas Glozar <tglozar@redhat.com>
[ Upstream commit 80967b354a76b360943af384c10d807d98bea5c4 ]
If either SIGINT is received twice, or after a SIGALRM (that is, after
timerlat was supposed to stop), abort processing events currently left
in the tracefs buffer and exit immediately.
This allows the user to exit rtla without waiting for processing all
events, should that take longer than wanted, at the cost of not
processing all samples.
Cc: John Kacur <jkacur@redhat.com>
Cc: Luis Goncalves <lgoncalv@redhat.com>
Cc: Gabriele Monaco <gmonaco@redhat.com>
Link: https://lore.kernel.org/20250116144931.649593-6-tglozar@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/tracing/rtla/src/timerlat_top.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index ac2ff38a57ee5..175e842d7e36c 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -893,6 +893,14 @@ static struct osnoise_tool
static int stop_tracing;
static void stop_top(int sig)
{
+ if (stop_tracing) {
+ /*
+ * Stop requested twice in a row; abort event processing and
+ * exit immediately
+ */
+ tracefs_iterate_stop(top_inst->inst);
+ return;
+ }
stop_tracing = 1;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-29 14:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-29 12:57 [PATCH AUTOSEL 6.12 1/4] scsi: storvsc: Ratelimit warning logs to prevent VM denial of service Sasha Levin
2025-01-29 12:57 ` [PATCH AUTOSEL 6.12 2/4] scsi: ufs: bsg: Set bsg_queue to NULL after removal Sasha Levin
2025-01-29 12:57 ` [PATCH AUTOSEL 6.12 3/4] rtla/timerlat_hist: Abort event processing on second signal Sasha Levin
2025-01-29 12:57 ` [PATCH AUTOSEL 6.12 4/4] rtla/timerlat_top: " Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox