All of lore.kernel.org
 help / color / mirror / Atom feed
From: Himanshu Madhani <himanshu.madhani@oracle.com>
To: Javed Hasan <jhasan@marvell.com>, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, GR-QLogic-Storage-Upstream@marvell.com
Subject: Re: [PATCH 2/2] libfc: Corrected the condition check and invalid argument passed
Date: Tue, 1 Jun 2021 13:00:05 -0500	[thread overview]
Message-ID: <6ae1223d-b8f0-56ec-c6f8-490a0a937eaf@oracle.com> (raw)
In-Reply-To: <20210601172156.31942-3-jhasan@marvell.com>



On 6/1/21 12:21 PM, Javed Hasan wrote:
>   -In correct condition check was leading to data corruption
>    and so the invalid argument.
> 
> Signed-off-by: Javed Hasan <jhasan@marvell.com>
> 
> ---
>   drivers/scsi/libfc/fc_encode.h | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/libfc/fc_encode.h b/drivers/scsi/libfc/fc_encode.h
> index 602c97a651bc..9ea4ceadb559 100644
> --- a/drivers/scsi/libfc/fc_encode.h
> +++ b/drivers/scsi/libfc/fc_encode.h
> @@ -166,9 +166,11 @@ static inline int fc_ct_ns_fill(struct fc_lport *lport,
>   static inline void fc_ct_ms_fill_attr(struct fc_fdmi_attr_entry *entry,
>   				    const char *in, size_t len)
>   {
> -	int copied = strscpy(entry->value, in, len);
> -	if (copied > 0)
> -		memset(entry->value, copied, len - copied);
> +	int copied;
> +
> +	copied = strscpy((char *)&entry->value, in, len);
> +	if (copied > 0 && (copied + 1) < len)
> +		memset((entry->value + copied + 1), 0, len - copied - 1);
>   }
>   
>   /**
> 

This should have Oracle Linux Engineering

Fixes: 8fd9efca86d08 ("scsi: libfc: Work around -Warray-bounds warning") 
  Cc: Stable@vger.kernel.org.

otherwise looks good.

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

-- 
Himanshu Madhani                                Oracle Linux Engineering

  reply	other threads:[~2021-06-01 18:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01 17:21 [PATCH 0/2] scsi: FDMI Fixes Javed Hasan
2021-06-01 17:21 ` [PATCH 1/2] scsi: fc: Corrected RHBA attributes length Javed Hasan
2021-06-01 17:52   ` Himanshu Madhani
2021-06-01 18:07     ` Himanshu Madhani
2021-06-02  6:01       ` [EXT] " Javed Hasan
2021-06-02 13:35         ` [EXT] " Himanshu Madhani
2021-06-01 17:21 ` [PATCH 2/2] libfc: Corrected the condition check and invalid argument passed Javed Hasan
2021-06-01 18:00   ` Himanshu Madhani [this message]
2021-06-03  9:56 [PATCH 0/2] scsi: FDMI Fixes Javed Hasan
2021-06-03  9:56 ` [PATCH 2/2] libfc: Corrected the condition check and invalid argument passed Javed Hasan

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=6ae1223d-b8f0-56ec-c6f8-490a0a937eaf@oracle.com \
    --to=himanshu.madhani@oracle.com \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=jhasan@marvell.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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 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.