Message ID | 20210601172156.31942-3-jhasan@marvell.com |
---|---|
State | Superseded |
Headers | show |
Series | scsi: FDMI Fixes | expand |
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>
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); } /**
-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(-)