All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Smart <jsmart2021@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: James Smart <jsmart2021@gmail.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>
Subject: [PATCH 05/10] lpfc: Fix ras_log via debugfs
Date: Wed, 18 Dec 2019 15:58:03 -0800	[thread overview]
Message-ID: <20191218235808.31922-6-jsmart2021@gmail.com> (raw)
In-Reply-To: <20191218235808.31922-1-jsmart2021@gmail.com>

/sys/kernel/debug/lpfc/fn0/ras_log always shows the same ras_log even if
there are link bounce events triggered via issue_lip

Dynamic FW logging had logic that prematurely breaks from the buffer
filling loop.

Fix the check for buffer overrun by looking before copying and restricting
copy length to the remaining buffer.  When copying, ensure space for NULL
character is left in the buffer.  While in the routine - ensure the buffer
is cleared before adding elements.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 2e6a68d9ea4f..d7504b2990a3 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -2085,6 +2085,8 @@ static int lpfc_debugfs_ras_log_data(struct lpfc_hba *phba,
 	int copied = 0;
 	struct lpfc_dmabuf *dmabuf, *next;
 
+	memset(buffer, 0, size);
+
 	spin_lock_irq(&phba->hbalock);
 	if (phba->ras_fwlog.state != ACTIVE) {
 		spin_unlock_irq(&phba->hbalock);
@@ -2094,10 +2096,15 @@ static int lpfc_debugfs_ras_log_data(struct lpfc_hba *phba,
 
 	list_for_each_entry_safe(dmabuf, next,
 				 &phba->ras_fwlog.fwlog_buff_list, list) {
+		/* Check if copying will go over size and a '\0' char */
+		if ((copied + LPFC_RAS_MAX_ENTRY_SIZE) >= (size - 1)) {
+			memcpy(buffer + copied, dmabuf->virt,
+			       size - copied - 1);
+			copied += size - copied - 1;
+			break;
+		}
 		memcpy(buffer + copied, dmabuf->virt, LPFC_RAS_MAX_ENTRY_SIZE);
 		copied += LPFC_RAS_MAX_ENTRY_SIZE;
-		if (size > copied)
-			break;
 	}
 	return copied;
 }
-- 
2.13.7


  parent reply	other threads:[~2019-12-18 23:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18 23:57 [PATCH 00/10] lpfc: Update lpfc to revision 12.6.0.3 James Smart
2019-12-18 23:57 ` [PATCH 01/10] lpfc: Fix incomplete NVME discovery when target James Smart
2019-12-18 23:58 ` [PATCH 02/10] lpfc: Fix: Rework setting of fdmi symbolic node name registration James Smart
2019-12-18 23:58 ` [PATCH 03/10] lpfc: Fix missing check for CSF in Write Object Mbox Rsp James Smart
2019-12-18 23:58 ` [PATCH 04/10] lpfc: Fix Fabric hostname registration if system hostname changes James Smart
2019-12-18 23:58 ` James Smart [this message]
2019-12-18 23:58 ` [PATCH 06/10] lpfc: Fix disablement of FC-AL on lpe35000 models James Smart
2019-12-18 23:58 ` [PATCH 07/10] lpfc: Fix unmap of dpp bars affecting next driver load James Smart
2019-12-18 23:58 ` [PATCH 08/10] lpfc: Fix MDS Latency Diagnostics Err-drop rates James Smart
2019-12-18 23:58 ` [PATCH 09/10] lpfc: Fix improper flag check for IO type James Smart
2019-12-18 23:58 ` [PATCH 10/10] lpfc: Update lpfc version to 12.6.0.3 James Smart
2019-12-20  3:36 ` [PATCH 00/10] lpfc: Update lpfc to revision 12.6.0.3 Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191218235808.31922-6-jsmart2021@gmail.com \
    --to=jsmart2021@gmail.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.