[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9829db9b8e207f5ffc57cfbe19a0d3b4d341a302.camel@linux.ibm.com>
Date: Wed, 20 Jan 2021 07:36:28 -0800
From: James Bottomley <jejb@...ux.ibm.com>
To: Jiapeng Zhong <abaci-bugfix@...ux.alibaba.com>, njavali@...vell.com
Cc: mrangankar@...vell.com, GR-QLogic-Storage-Upstream@...vell.com,
martin.petersen@...cle.com, linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drivers/scsi/qla4xxx: use scnprintf() instead of
snprintf()
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@...ux.alibaba.com>
> Signed-off-by: Jiapeng Zhong <abaci-bugfix@...ux.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
Powered by blists - more mailing lists