mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Bottomley <jejb@linux.ibm.com>
To: Jiapeng Zhong <abaci-bugfix@linux.alibaba.com>, njavali@marvell.com
Cc: mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/scsi/qla4xxx: use scnprintf() instead of snprintf()
Date: Wed, 20 Jan 2021 07:36:28 -0800	[thread overview]
Message-ID: <9829db9b8e207f5ffc57cfbe19a0d3b4d341a302.camel@linux.ibm.com> (raw)
In-Reply-To: <1611127365-45929-1-git-send-email-abaci-bugfix@linux.alibaba.com>

On Wed, 2021-01-20 at 15:22 +0800, Jiapeng Zhong wrote:
> Fix the following coccicheck warning:
> 
> ./drivers/scsi/qla4xxx/ql4_attr.c: WARNING: use scnprintf or
> sprintf
> 
> The snprintf() function returns the number of characters which would
> have been printed if there were enough space, but the scnprintf()
> returns the number of characters which were actually printed.  If
> the buffer is not large enough, then using snprintf() would result
> in a read overflow and an information leak.
> 
> Reported-by: Abaci Robot<abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Zhong <abaci-bugfix@linux.alibaba.com>
> ---
>  drivers/scsi/qla4xxx/ql4_attr.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/scsi/qla4xxx/ql4_attr.c
> b/drivers/scsi/qla4xxx/ql4_attr.c
> index ec43528..1a16017 100644
> --- a/drivers/scsi/qla4xxx/ql4_attr.c
> +++ b/drivers/scsi/qla4xxx/ql4_attr.c
> @@ -170,7 +170,7 @@ void qla4_8xxx_free_sysfs_attr(struct
> scsi_qla_host *ha)
>  			char *buf)
>  {
>  	struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
> -	return snprintf(buf, PAGE_SIZE, "%s\n", ha->serial_number);
> +	return scnprintf(buf, PAGE_SIZE, "%s\n", ha->serial_number);

This is the wrong ABI to be replacing anything sysfs with, it should be
sysfs_emit()

James



      reply	other threads:[~2021-01-20 15:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20  7:22 Jiapeng Zhong
2021-01-20 15:36 ` James Bottomley [this message]

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=9829db9b8e207f5ffc57cfbe19a0d3b4d341a302.camel@linux.ibm.com \
    --to=jejb@linux.ibm.com \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=abaci-bugfix@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mrangankar@marvell.com \
    --cc=njavali@marvell.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®