Re: [PATCH 6/6] scsi: qedf: use correct strncpy() size

2018-02-09 Thread Martin K. Petersen

Arnd,

> gcc-8 warns during link-time optimization that the strncpy() call
> passes the size of the source buffer rather than the destination:

Applied to 4.17/scsi-queue. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 6/6] scsi: qedf: use correct strncpy() size

2018-02-07 Thread Chad Dupuis

On Fri, 2 Feb 2018, 8:12am, Arnd Bergmann wrote:

> gcc-8 warns during link-time optimization that the strncpy() call
> passes the size of the source buffer rather than the destination:
> 
> drivers/scsi/qedf/qedf_dbg.c: In function 'qedf_uevent_emit':
> include/linux/string.h:253: error: 'strncpy' specified bound depends on the 
> length of the source argument [-Werror=stringop-overflow=]
> 
> This changes it to strscpy() with the correct length, guaranteeing
> a properly nul-terminated string of the right size.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/scsi/qedf/qedf_dbg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reasonable security precaution.

Acked-by: Chad Dupuis 


Re: [PATCH 6/6] scsi: qedf: use correct strncpy() size

2018-02-04 Thread kbuild test robot
Hi Arnd,

I love your patch! Perhaps something to improve:

[auto build test WARNING on scsi/for-next]
[also build test WARNING on v4.15]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Arnd-Bergmann/scsi-fixes-for-building-with-LTO/20180205-083607
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 7.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   drivers/scsi//qedf/qedf_dbg.c: In function 'qedf_uevent_emit':
>> drivers/scsi//qedf/qedf_dbg.c:163:4: warning: ignoring return value of 
>> 'strscpy', declared with attribute warn_unused_result [-Wunused-result]
   strscpy(event_string, msg, sizeof(event_string));
   ^~~~

vim +/strscpy +163 drivers/scsi//qedf/qedf_dbg.c

   152  
   153  void
   154  qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg)
   155  {
   156  char event_string[40];
   157  char *envp[] = {event_string, NULL};
   158  
   159  memset(event_string, 0, sizeof(event_string));
   160  switch (code) {
   161  case QEDF_UEVENT_CODE_GRCDUMP:
   162  if (msg)
 > 163  strscpy(event_string, msg, 
 > sizeof(event_string));
   164  else
   165  sprintf(event_string, "GRCDUMP=%u", 
shost->host_no);
   166  break;
   167  default:
   168  /* do nothing */
   169  break;
   170  }
   171  
   172  kobject_uevent_env(>shost_gendev.kobj, KOBJ_CHANGE, 
envp);
   173  }
   174  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip