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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 12 Apr 2019 17:20:02 +0800
From:   YueHaibing <yuehaibing@...wei.com>
To:     Colin King <colin.king@...onical.com>,
        <QLogic-Storage-Upstream@...ium.com>,
        "James E . J . Bottomley" <jejb@...ux.ibm.com>,
        "Martin K . Petersen" <martin.petersen@...cle.com>,
        <linux-scsi@...r.kernel.org>
CC:     <kernel-janitors@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] scsi: qedf: replace memset/memcpy with safer strscpy


I send a similar fix earlier, but it seems not be picked.

https://patchwork.kernel.org/patch/10874565/

On 2019/4/12 17:05, Colin King wrote:
> From: Colin Ian King <colin.king@...onical.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. Replace the
> memset/memcpy calls with the safer strscpy as this won't overrun
> the end of the source string and it ensures the destination
> string is always terminated with NUL.
> 
> 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@...onical.com>
> ---
>  drivers/scsi/qedf/qedf_dbg.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/qedf/qedf_dbg.c b/drivers/scsi/qedf/qedf_dbg.c
> index f2397ee9ba69..b491bebeaca9 100644
> --- a/drivers/scsi/qedf/qedf_dbg.c
> +++ b/drivers/scsi/qedf/qedf_dbg.c
> @@ -17,8 +17,7 @@ qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
>  	struct va_format vaf;
>  	char nfunc[32];
>  
> -	memset(nfunc, 0, sizeof(nfunc));
> -	memcpy(nfunc, func, sizeof(nfunc) - 1);
> +	strscpy(nfunc, func, sizeof(nfunc));
>  
>  	va_start(va, fmt);
>  
> @@ -42,8 +41,7 @@ qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
>  	struct va_format vaf;
>  	char nfunc[32];
>  
> -	memset(nfunc, 0, sizeof(nfunc));
> -	memcpy(nfunc, func, sizeof(nfunc) - 1);
> +	strscpy(nfunc, func, sizeof(nfunc));
>  
>  	va_start(va, fmt);
>  
> @@ -71,8 +69,7 @@ qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
>  	struct va_format vaf;
>  	char nfunc[32];
>  
> -	memset(nfunc, 0, sizeof(nfunc));
> -	memcpy(nfunc, func, sizeof(nfunc) - 1);
> +	strscpy(nfunc, func, sizeof(nfunc));
>  
>  	va_start(va, fmt);
>  
> @@ -101,8 +98,7 @@ qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
>  	struct va_format vaf;
>  	char nfunc[32];
>  
> -	memset(nfunc, 0, sizeof(nfunc));
> -	memcpy(nfunc, func, sizeof(nfunc) - 1);
> +	strscpy(nfunc, func, sizeof(nfunc));
>  
>  	va_start(va, fmt);
>  
> 

Powered by blists - more mailing lists