LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Saurav Kashyap <skashyap@marvell.com>
To: Colin King <colin.king@canonical.com>,
	"QLogic-Storage-Upstream@cavium.com" 
	<QLogic-Storage-Upstream@cavium.com>,
	"James E . J . Bottomley" <jejb@linux.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Cc: "kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][V2] scsi: qedf: remove memset/memcpy to nfunc and use func instead
Date: Thu, 18 Apr 2019 08:13:34 +0000	[thread overview]
Message-ID: <D8DE2F28.187A3%skashyap@marvell.com> (raw)
In-Reply-To: <20190412094829.15868-1-colin.king@canonical.com>



-----Original Message-----
From: Colin King <colin.king@canonical.com>
Date: Friday, 12 April 2019 at 3:18 PM
To: <QLogic-Storage-Upstream@cavium.com>, "James E . J . Bottomley"
<jejb@linux.ibm.com>, "Martin K . Petersen" <martin.petersen@oracle.com>,
<linux-scsi@vger.kernel.org>
Cc: <kernel-janitors@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH][V2] scsi: qedf: remove memset/memcpy to nfunc and use
func instead
Resent-From: <Saurav.Kashyap@cavium.com>
Resent-Date: Fri, 12 Apr 2019 02:48:45 -0700

>From: Colin Ian King <colin.king@canonical.com>
>
>Currently the qedf_dbg_* family of functions can overrun the end
>of the source string if it is less than the destination buffer
>length because of the use of a fixed sized memcpy. Remove the
>memset/memcpy calls to nfunc and just use func instead as it
>is always a null terminated string.
>
>Addresses-Coverity: ("Out-of-bounds access")
>Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver
>framework.")
>Signed-off-by: Colin Ian King <colin.king@canonical.com>
>---
>
>V2: replace the V1 strscpy with just using func since this is always
>    going to be a NUL terminated string. Thanks to Rasmus Villemoes for
>    noticing that.
>
>---
> drivers/scsi/qedf/qedf_dbg.c | 32 ++++++++------------------------
> 1 file changed, 8 insertions(+), 24 deletions(-)
>
>diff --git a/drivers/scsi/qedf/qedf_dbg.c b/drivers/scsi/qedf/qedf_dbg.c
>index f2397ee9ba69..f7d170bffc82 100644
>--- a/drivers/scsi/qedf/qedf_dbg.c
>+++ b/drivers/scsi/qedf/qedf_dbg.c
>@@ -15,10 +15,6 @@ qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char
>*func, u32 line,
> {
> 	va_list va;
> 	struct va_format vaf;
>-	char nfunc[32];
>-
>-	memset(nfunc, 0, sizeof(nfunc));
>-	memcpy(nfunc, func, sizeof(nfunc) - 1);
> 
> 	va_start(va, fmt);
> 
>@@ -27,9 +23,9 @@ qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char
>*func, u32 line,
> 
> 	if (likely(qedf) && likely(qedf->pdev))
> 		pr_err("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf->pdev->dev)),
>-			nfunc, line, qedf->host_no, &vaf);
>+			func, line, qedf->host_no, &vaf);
> 	else
>-		pr_err("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
>+		pr_err("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
> 
> 	va_end(va);
> }
>@@ -40,10 +36,6 @@ qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char
>*func, u32 line,
> {
> 	va_list va;
> 	struct va_format vaf;
>-	char nfunc[32];
>-
>-	memset(nfunc, 0, sizeof(nfunc));
>-	memcpy(nfunc, func, sizeof(nfunc) - 1);
> 
> 	va_start(va, fmt);
> 
>@@ -55,9 +47,9 @@ qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char
>*func, u32 line,
> 
> 	if (likely(qedf) && likely(qedf->pdev))
> 		pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf->pdev->dev)),
>-			nfunc, line, qedf->host_no, &vaf);
>+			func, line, qedf->host_no, &vaf);
> 	else
>-		pr_warn("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
>+		pr_warn("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
> 
> ret:
> 	va_end(va);
>@@ -69,10 +61,6 @@ qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char
>*func, u32 line,
> {
> 	va_list va;
> 	struct va_format vaf;
>-	char nfunc[32];
>-
>-	memset(nfunc, 0, sizeof(nfunc));
>-	memcpy(nfunc, func, sizeof(nfunc) - 1);
> 
> 	va_start(va, fmt);
> 
>@@ -84,10 +72,10 @@ qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char
>*func, u32 line,
> 
> 	if (likely(qedf) && likely(qedf->pdev))
> 		pr_notice("[%s]:[%s:%d]:%d: %pV",
>-			  dev_name(&(qedf->pdev->dev)), nfunc, line,
>+			  dev_name(&(qedf->pdev->dev)), func, line,
> 			  qedf->host_no, &vaf);
> 	else
>-		pr_notice("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
>+		pr_notice("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
> 
> ret:
> 	va_end(va);
>@@ -99,10 +87,6 @@ qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char
>*func, u32 line,
> {
> 	va_list va;
> 	struct va_format vaf;
>-	char nfunc[32];
>-
>-	memset(nfunc, 0, sizeof(nfunc));
>-	memcpy(nfunc, func, sizeof(nfunc) - 1);
> 
> 	va_start(va, fmt);
> 
>@@ -114,9 +98,9 @@ qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char
>*func, u32 line,
> 
> 	if (likely(qedf) && likely(qedf->pdev))
> 		pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf->pdev->dev)),
>-			nfunc, line, qedf->host_no, &vaf);
>+			func, line, qedf->host_no, &vaf);
> 	else
>-		pr_info("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
>+		pr_info("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
> 
> ret:
> 	va_end(va);
>-- 
>2.20.1

Thanks,
Acked-by: Saurav Kashyap <skashyap@marvell.com>


>


  reply	other threads:[~2019-04-18  8:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-12  9:48 Colin King
2019-04-18  8:13 ` Saurav Kashyap [this message]
2019-04-19  0:33 ` Martin K. Petersen
2019-04-20  4:05 ` [PATCH] scsi: qedi: " Yue Haibing
2019-05-09 14:50   ` YueHaibing
2019-05-10 11:29   ` Dan Carpenter
2019-05-13 22:31   ` 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=D8DE2F28.187A3%skashyap@marvell.com \
    --to=skashyap@marvell.com \
    --cc=QLogic-Storage-Upstream@cavium.com \
    --cc=colin.king@canonical.com \
    --cc=jejb@linux.ibm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --subject='Re: [PATCH][V2] scsi: qedf: remove memset/memcpy to nfunc and use func instead' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).