lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Tue, 10 Dec 2019 15:21:07 +0100
From:   Arne Jansen <sensille@....net>
To:     linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     jejb@...ux.ibm.com, martin.petersen@...cle.com
Subject: [PATCH] scsi_lib: ratelimit printk in scsi_prep_state_check

scsi_prep_state_check is called with the queue_lock held, called from
scsi_internal_device_unblock.
The same lock is also acquired in softirq context from scsi_end_request.
If the output overwhelms the serial console, the machine effectively
comes to a halt, even triggering a hardware watchdog.

This patch ratelimits the output.

Signed-off-by: Arne Jansen <sensille@....net>
---
  drivers/scsi/scsi_lib.c | 14 ++++++++++----
  1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 3e7a45d0daca..33432108d6aa 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1232,6 +1232,10 @@ static blk_status_t scsi_setup_cmnd(struct
scsi_device *sdev,
  static blk_status_t
  scsi_prep_state_check(struct scsi_device *sdev, struct request *req)
  {
+       static DEFINE_RATELIMIT_STATE(_rs,
+               DEFAULT_RATELIMIT_INTERVAL,
+               DEFAULT_RATELIMIT_BURST);
+
         switch (sdev->sdev_state) {
         case SDEV_OFFLINE:
         case SDEV_TRANSPORT_OFFLINE:
@@ -1240,16 +1244,18 @@ scsi_prep_state_check(struct scsi_device *sdev,
struct request *req)
                  * commands.  The device must be brought online
                  * before trying any recovery commands.
                  */
-               sdev_printk(KERN_ERR, sdev,
-                           "rejecting I/O to offline device\n");
+               if (__ratelimit(&_rs))
+                       sdev_printk(KERN_ERR, sdev,
+                                   "rejecting I/O to offline device\n");
                 return BLK_STS_IOERR;
         case SDEV_DEL:
                 /*
                  * If the device is fully deleted, we refuse to
                  * process any commands as well.
                  */
-               sdev_printk(KERN_ERR, sdev,
-                           "rejecting I/O to dead device\n");
+               if (__ratelimit(&_rs))
+                       sdev_printk(KERN_ERR, sdev,
+                                   "rejecting I/O to dead device\n");
                 return BLK_STS_IOERR;
         case SDEV_BLOCK:
         case SDEV_CREATED_BLOCK:
--
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ