scsi: fixes for building with LTO
Subsystems (4)
cover scsi: fixes for building with LTO
I experimented with link time optimization after Nico's article at https://lwn.net/Articles/744507/
Here is a set of patches that came out of it for the scsi subsystem.
Arnd Bergmann (6):
scsi: fc_encode: work around strncpy size warnings
scsi: NCR53c406a: avoid section mismatch with LTO
scsi: sym53c416: avoid section mismatch with LTO
scsi: qedf: fix LTO-enabled build
scsi: qedi: fix building with LTO
scsi: qedf: use correct strncpy() size
drivers/scsi/NCR53c406a.c | 2 +- drivers/scsi/qedf/qedf_dbg.c | 2 +- drivers/scsi/qedf/qedf_dbg.h | 17 ++++++++++------- drivers/scsi/qedf/qedf_debugfs.c | 6 +++--- drivers/scsi/qedf/qedf_main.c | 8 +++----- drivers/scsi/qedi/qedi_dbg.h | 2 +- drivers/scsi/qedi/qedi_debugfs.c | 4 ++-- drivers/scsi/qedi/qedi_gbl.h | 4 ++-- drivers/scsi/qedi/qedi_main.c | 4 ++-- drivers/scsi/sym53c416.c | 2 +- include/scsi/fc/fc_ms.h | 2 +- 11 files changed, 27 insertions(+), 26 deletions(-)
Signature · 1 line
2.9.0
PATCH 1/6 scsi: fc_encode: work around strncpy size warnings
struct fc_fdmi_attr_entry contains a variable-length string at the end, which is encoded as a one-byte array. gcc-8 notices that we copy strings into it that obviously go beyond that one byte:
In function 'fc_ct_ms_fill',
inlined from 'fc_elsct_send' at include/scsi/fc_encode.h:518:8:include/scsi/fc_encode.h:275:3: error: 'strncpy' writing 64 bytes into a region of size 1 overflows the destination [-Werror=stringop-overflow=]
strncpy((char *)&entry->value,
^include/scsi/fc_encode.h:287:3: error: 'strncpy' writing 64 bytes into a region of size 1 overflows the destination [-Werror=stringop-overflow=]
strncpy((char *)&entry->value,
^
No idea what the right fix is.
--- include/scsi/fc/fc_ms.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/scsi/fc/fc_ms.h +1 -1
@@ -128,7 +128,7 @@ struct fc_fdmi_port_name {struct fc_fdmi_attr_entry {__be16 type;__be16 len; -__u8 value[1 ]; +__u8 value[]; } __attribute__((__packed__ ));/*
Signature · 1 line
2.9.0
PATCH 2/6 scsi: NCR53c406a: avoid section mismatch with LTO
In reply to Arnd BergmannBuilding with link time optimizations produces a false-postive section mismatch warning:
WARNING: vmlinux.o(.data+0xf7e8): Section mismatch in reference from the variable driver_template.lto_priv.6914 to the function .init.text:NCR53c406a_detect() The variable driver_template.lto_priv.6914 references
the function __init NCR53c406a_detect()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
The ->detect callback is always entered from the init_this_scsi_driver() init function, but apparently LTO turns the optimized direct function call into an indirect call through a non-__initdata pointer.
All drivers using init_this_scsi_driver() are for ancient hardware, and most don't mark the detect() callback as __init(), so I'm just removing the annotation here to kill off the warning instead of doing a larger rework.
--- drivers/scsi/NCR53c406a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/NCR53c406a.c +1 -1
@@ -448,7 +448,7 @@ static __inline__ int NCR53c406a_pio_write(unsigned char *request, unsigned int }#endif /* USE_PIO */ -static int __init NCR53c406a_detect (struct scsi_host_template * tpnt) +static int NCR53c406a_detect (struct scsi_host_template * tpnt) {int present =0 ;struct Scsi_Host *shpnt =NULL ;
Signature · 1 line
2.9.0
Martin K. Petersen
AppliedRe: [PATCH 2/6] scsi: NCR53c406a: avoid section mismatch with LTO
Arnd,
Quoted 2 lines
Building with link time optimizations produces a false-postive section mismatch warning:
Applied to 4.17/scsi-queue, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH 3/6 scsi: sym53c416: avoid section mismatch with LTO
In reply to Arnd BergmannBuilding with link time optimizations produces a false-postive section mismatch warning:
WARNING: vmlinux.o(.data+0xf8c8): Section mismatch in reference from the variable driver_template.lto_priv.6915 to the function .init.text:sym53c416_detect() The variable driver_template.lto_priv.6915 references
the function __init sym53c416_detect()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
The ->detect callback is always entered from the init_this_scsi_driver() init function, but apparently LTO turns the optimized direct function call into an indirect call through a non-__initdata pointer.
All drivers using init_this_scsi_driver() are for ancient hardware, and most don't mark the detect() callback as __init(), so I'm just removing the annotation here to kill off the warning instead of doing a larger rework.
--- drivers/scsi/sym53c416.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sym53c416.c +1 -1
@@ -608,7 +608,7 @@ static void sym53c416_probe(void) } } -int __init sym53c416_detect (struct scsi_host_template *tpnt) +int sym53c416_detect (struct scsi_host_template *tpnt) {unsigned long flags;struct Scsi_Host * shpnt =NULL ;
Signature · 1 line
2.9.0
Martin K. Petersen
AppliedRe: [PATCH 3/6] scsi: sym53c416: avoid section mismatch with LTO
Arnd,
Quoted 2 lines
Building with link time optimizations produces a false-postive section mismatch warning:
Applied to 4.17/scsi-queue, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH 4/6 scsi: qedf: fix LTO-enabled build
In reply to Arnd BergmannThe prototype for qedf_dbg_fops/qedf_debugfs_ops doesn't match the definition, which causes the final link to fail with link-time optimizations:
drivers/scsi/qedf/qedf_main.c:34: error: type of 'qedf_dbg_fops' does not match original declaration [-Werror=lto-type-mismatch]
extern struct file_operations qedf_dbg_fops;
drivers/scsi/qedf/qedf_debugfs.c:443: note: 'qedf_dbg_fops' was previously declared here
const struct file_operations qedf_dbg_fops[] = {
drivers/scsi/qedf/qedf_main.c:33: error: type of 'qedf_debugfs_ops' does not match original declaration [-Werror=lto-type-mismatch]
extern struct qedf_debugfs_ops qedf_debugfs_ops;
drivers/scsi/qedf/qedf_debugfs.c:102: note: 'qedf_debugfs_ops' was previously declared here
struct qedf_debugfs_ops qedf_debugfs_ops[] = {
This corrects the prototype and moves it into a shared header file where it belongs. The file operations can also be marked 'const' like the qedf_debugfs_ops.
--- drivers/scsi/qedf/qedf_dbg.h | 17 ++++++++++------- drivers/scsi/qedf/qedf_debugfs.c | 6 +++--- drivers/scsi/qedf/qedf_main.c | 8 +++----- 3 files changed, 16 insertions(+), 15 deletions(-)
drivers/scsi/qedf/qedf_dbg.h +10 -7
@@ -116,6 +116,14 @@ extern int qedf_create_sysfs_attr(struct Scsi_Host *shost,extern void qedf_remove_sysfs_attr (struct Scsi_Host *shost,struct sysfs_bin_attrs *iter); +struct qedf_debugfs_ops { +char *name; +struct qedf_list_of_funcs *qedf_funcs; +}; + +extern const struct qedf_debugfs_ops qedf_debugfs_ops[]; +extern const struct file_operations qedf_dbg_fops[]; +#ifdef CONFIG_DEBUG_FS /* DebugFS related code */ struct qedf_list_of_funcs {
@@ -123,11 +131,6 @@ struct qedf_list_of_funcs {ssize_t (*oper_func)(struct qedf_dbg_ctx *qedf); }; -struct qedf_debugfs_ops { -char *name; -struct qedf_list_of_funcs *qedf_funcs; -}; -#define qedf_dbg_fileops (drv, ops) \ { \ .owner = THIS_MODULE, \
@@ -147,8 +150,8 @@ struct qedf_debugfs_ops { }extern void qedf_dbg_host_init (struct qedf_dbg_ctx *qedf, -struct qedf_debugfs_ops *dops, -struct file_operations *fops); +const struct qedf_debugfs_ops *dops, +const struct file_operations *fops);extern void qedf_dbg_host_exit (struct qedf_dbg_ctx *qedf);extern void qedf_dbg_init (char *drv_name);extern void qedf_dbg_exit (void );
drivers/scsi/qedf/qedf_debugfs.c +3 -3
@@ -23,8 +23,8 @@ static struct dentry *qedf_dbg_root;**/ void qedf_dbg_host_init (struct qedf_dbg_ctx *qedf, -struct qedf_debugfs_ops *dops, -struct file_operations *fops) +const struct qedf_debugfs_ops *dops, +const struct file_operations *fops) {char host_dirname[32 ];struct dentry *file_dentry =NULL ;
@@ -99,7 +99,7 @@ qedf_dbg_exit(void) qedf_dbg_root =NULL ; } -struct qedf_debugfs_ops qedf_debugfs_ops[] = { +const struct qedf_debugfs_ops qedf_debugfs_ops[] = { {"fp_int" ,NULL }, {"io_trace" ,NULL }, {"debug" ,NULL },
drivers/scsi/qedf/qedf_main.c +3 -5
@@ -23,6 +23,7 @@#include <linux/if_vlan.h> #include <linux/cpu.h> #include "qedf.h" +#include "qedf_dbg.h" #include <uapi/linux/pci_regs.h> const struct qed_fcoe_ops *qed_ops;
@@ -30,9 +31,6 @@ const struct qed_fcoe_ops *qed_ops;static int qedf_probe (struct pci_dev *pdev,const struct pci_device_id *id);static void qedf_remove (struct pci_dev *pdev); -extern struct qedf_debugfs_ops qedf_debugfs_ops; -extern struct file_operations qedf_dbg_fops; -/* * Driver module parameters. */
@@ -3155,8 +3153,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode) }#ifdef CONFIG_DEBUG_FS -qedf_dbg_host_init (&(qedf->dbg_ctx), &qedf_debugfs_ops, - &qedf_dbg_fops); +qedf_dbg_host_init (&(qedf->dbg_ctx), qedf_debugfs_ops, + qedf_dbg_fops);#endif /* Start LL2 */
Signature · 1 line
2.9.0
Re: [PATCH 4/6] scsi: qedf: fix LTO-enabled build
Quoted 19 lines · Arnd Bergmann
The prototype for qedf_dbg_fops/qedf_debugfs_ops doesn't match the definition, which causes the final link to fail with link-time optimizations:
drivers/scsi/qedf/qedf_main.c:34: error: type of 'qedf_dbg_fops' does not match original declaration [-Werror=lto-type-mismatch]
extern structfile_operationsqedf_dbg_fops;
drivers/scsi/qedf/qedf_debugfs.c:443: note: 'qedf_dbg_fops' was previously declared here
const structfile_operationsqedf_dbg_fops[] = {
drivers/scsi/qedf/qedf_main.c:33: error: type of 'qedf_debugfs_ops' does not match original declaration [-Werror=lto-type-mismatch]
extern structqedf_debugfs_opsqedf_debugfs_ops;
drivers/scsi/qedf/qedf_debugfs.c:102: note: 'qedf_debugfs_ops' was previously declared here
structqedf_debugfs_opsqedf_debugfs_ops[] = {This corrects the prototype and moves it into a shared header file where it belongs. The file operations can also be marked 'const' like the
qedf_debugfs_ops.
Quoted 7 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/scsi/qedf/qedf_dbg.h | 17 ++++++++++------- drivers/scsi/qedf/qedf_debugfs.c | 6 +++--- drivers/scsi/qedf/qedf_main.c | 8 +++----- 3 files changed, 16 insertions(+), 15 deletions(-)
Thanks.
Martin K. Petersen
AppliedRe: [PATCH 4/6] scsi: qedf: fix LTO-enabled build
In reply to Arnd BergmannArnd,
Quoted 3 lines
The prototype for qedf_dbg_fops/qedf_debugfs_ops doesn't match the definition, which causes the final link to fail with link-time optimizations:
Applied to 4.17/scsi-queue. Thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH 5/6 scsi: qedi: fix building with LTO
In reply to Arnd BergmannWhen link-time optimizations are enabled, qedi fails to build because of mismatched prototypes:
drivers/scsi/qedi/qedi_gbl.h:27:37: error: type of 'qedi_dbg_fops' does not match original declaration [-Werror=lto-type-mismatch]
extern const struct file_operations qedi_dbg_fops;
^
drivers/scsi/qedi/qedi_debugfs.c:239:30: note: 'qedi_dbg_fops' was previously declared here
const struct file_operations qedi_dbg_fops[] = {
^
drivers/scsi/qedi/qedi_gbl.h:26:32: error: type of 'qedi_debugfs_ops' does not match original declaration [-Werror=lto-type-mismatch]
extern struct qedi_debugfs_ops qedi_debugfs_ops;
^drivers/scsi/qedi/qedi_debugfs.c:102:25: note: 'qedi_debugfs_ops' was previously declared here
struct qedi_debugfs_ops qedi_debugfs_ops[] = {
This changes the declaration to match the definition, and adapts the users as necessary. Since both array can be constant here, I'm adding the 'const' everywhere for consistency.
--- drivers/scsi/qedi/qedi_dbg.h | 2 +- drivers/scsi/qedi/qedi_debugfs.c | 4 ++-- drivers/scsi/qedi/qedi_gbl.h | 4 ++-- drivers/scsi/qedi/qedi_main.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)
drivers/scsi/qedi/qedi_dbg.h +1 -1
@@ -134,7 +134,7 @@ struct qedi_debugfs_ops { }void qedi_dbg_host_init (struct qedi_dbg_ctx *qedi, -struct qedi_debugfs_ops *dops, +const struct qedi_debugfs_ops *dops,const struct file_operations *fops);void qedi_dbg_host_exit (struct qedi_dbg_ctx *qedi);void qedi_dbg_init (char *drv_name);
drivers/scsi/qedi/qedi_debugfs.c +2 -2
@@ -19,7 +19,7 @@ static struct dentry *qedi_dbg_root;void qedi_dbg_host_init (struct qedi_dbg_ctx *qedi, -struct qedi_debugfs_ops *dops, +const struct qedi_debugfs_ops *dops,const struct file_operations *fops) {char host_dirname[32 ];
@@ -99,7 +99,7 @@ static struct qedi_list_of_funcs qedi_dbg_do_not_recover_ops[] = { { NULL, NULL } }; -struct qedi_debugfs_ops qedi_debugfs_ops[] = { +const struct qedi_debugfs_ops qedi_debugfs_ops[] = { {"gbl_ctx" ,NULL }, {"do_not_recover" , qedi_dbg_do_not_recover_ops}, {"io_trace" ,NULL },
drivers/scsi/qedi/qedi_gbl.h +2 -2
@@ -23,8 +23,8 @@ extern uint qedi_io_tracing;extern struct scsi_host_template qedi_host_template;extern struct iscsi_transport qedi_iscsi_transport;extern const struct qed_iscsi_ops *qedi_ops; -extern struct qedi_debugfs_ops qedi_debugfs_ops; -extern const struct file_operations qedi_dbg_fops; +extern const struct qedi_debugfs_ops qedi_debugfs_ops[]; +extern const struct file_operations qedi_dbg_fops[];extern struct device_attribute *qedi_shost_attrs[];int qedi_alloc_sq (struct qedi_ctx *qedi,struct qedi_endpoint *ep);
drivers/scsi/qedi/qedi_main.c +2 -2
@@ -2303,8 +2303,8 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) }#ifdef CONFIG_DEBUG_FS -qedi_dbg_host_init (&qedi->dbg_ctx, &qedi_debugfs_ops, - &qedi_dbg_fops); +qedi_dbg_host_init (&qedi->dbg_ctx, qedi_debugfs_ops, + qedi_dbg_fops);#endif QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, "QLogic FastLinQ iSCSI Module qedi %s, FW %d.%d.%d.%d\n",
Signature · 1 line
2.9.0
Re: [PATCH 5/6] scsi: qedi: fix building with LTO
Quoted 98 lines · Arnd Bergmann
When link-time optimizations are enabled, qedi fails to build because of mismatched prototypes:
drivers/scsi/qedi/qedi_gbl.h:27:37: error: type of 'qedi_dbg_fops' does not match original declaration [-Werror=lto-type-mismatch]extern const struct file_operations qedi_dbg_fops; ^ drivers/scsi/qedi/qedi_debugfs.c:239:30: note: 'qedi_dbg_fops' was previously declared here const struct file_operations qedi_dbg_fops[] = { ^ drivers/scsi/qedi/qedi_gbl.h:26:32: error: type of 'qedi_debugfs_ops' does not match original declaration [-Werror=lto-type-mismatch] extern struct qedi_debugfs_ops qedi_debugfs_ops; ^
drivers/scsi/qedi/qedi_debugfs.c:102:25: note: 'qedi_debugfs_ops' was previously declared here
structqedi_debugfs_opsqedi_debugfs_ops[] = {This changes the declaration to match the definition, and adapts the users as necessary. Since both array can be constant here, I'm adding the 'const' everywhere for consistency.
Signed-off-by Arnd Bergmann <[email protected]>---
drivers/scsi/qedi/qedi_dbg.h | 2 +- drivers/scsi/qedi/qedi_debugfs.c | 4 ++-- drivers/scsi/qedi/qedi_gbl.h | 4 ++-- drivers/scsi/qedi/qedi_main.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)drivers/scsi/qedi/qedi_dbg.h +1
-1@@ -134,7 +134,7 @@ struct qedi_debugfs_ops { }void qedi_dbg_host_init (struct qedi_dbg_ctx *qedi, -struct qedi_debugfs_ops *dops, +const struct qedi_debugfs_ops *dops,const struct file_operations *fops);void qedi_dbg_host_exit (struct qedi_dbg_ctx *qedi);void qedi_dbg_init (char *drv_name);drivers/scsi/qedi/qedi_debugfs.c +0
-0@@ -19,7 +19,7 @@ static struct dentry *qedi_dbg_root;void
qedi_dbg_host_init(structqedi_dbg_ctx*qedi,drivers/scsi/qedi/qedi_debugfs.c +1
-1- struct qedi_debugfs_ops *dops, + const struct qedi_debugfs_ops *dops,const struct
file_operations*fops){ char host_dirname[32];drivers/scsi/qedi/qedi_debugfs.c +1
-1@@ -99,7 +99,7 @@ static struct qedi_list_of_funcs qedi_dbg_do_not_recover_ops[] = { { NULL, NULL } }; -struct qedi_debugfs_ops qedi_debugfs_ops[] = { +const struct qedi_debugfs_ops qedi_debugfs_ops[] = { {"gbl_ctx" ,NULL }, {"do_not_recover" , qedi_dbg_do_not_recover_ops},{ "io_trace", NULL },drivers/scsi/qedi/qedi_gbl.h +2
-2@@ -23,8 +23,8 @@ extern uint qedi_io_tracing;extern struct scsi_host_template qedi_host_template;extern struct iscsi_transport qedi_iscsi_transport;extern const struct qed_iscsi_ops *qedi_ops; -extern struct qedi_debugfs_ops qedi_debugfs_ops; -extern const struct file_operations qedi_dbg_fops; +extern const struct qedi_debugfs_ops qedi_debugfs_ops[]; +extern const struct file_operations qedi_dbg_fops[];extern struct device_attribute *qedi_shost_attrs[];int qedi_alloc_sq (struct qedi_ctx *qedi,struct qedi_endpoint *ep);drivers/scsi/qedi/qedi_main.c +2
-2@@ -2303,8 +2303,8 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) }#ifdef CONFIG_DEBUG_FS -qedi_dbg_host_init (&qedi->dbg_ctx, &qedi_debugfs_ops, - &qedi_dbg_fops); +qedi_dbg_host_init (&qedi->dbg_ctx, qedi_debugfs_ops, + qedi_dbg_fops);#endif QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
Quoted 3 lines
"QLogic FastLinQ iSCSI Module qedi %s, FW %d.%d.%d.%d\n",
Signature · 1 line
2.9.0
Thanks
Quoted 1 line
Martin K. Petersen
AppliedRe: [PATCH 5/6] scsi: qedi: fix building with LTO
In reply to Arnd BergmannArnd,
Quoted 2 lines
When link-time optimizations are enabled, qedi fails to build because of mismatched prototypes:
Applied to 4.17/scsi-queue. Thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH 6/6 scsi: qedf: use correct strncpy() size
In reply to Arnd Bergmanngcc-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.
--- drivers/scsi/qedf/qedf_dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qedf/qedf_dbg.c +1 -1
@@ -160,7 +160,7 @@ qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg)switch (code) {case QEDF_UEVENT_CODE_GRCDUMP :if (msg) -strncpy (event_string, msg,strlen (msg)); +strscpy (event_string, msg,sizeof (event_string));else sprintf (event_string,"GRCDUMP=%u" , shost->host_no);break ;
Signature · 1 line
2.9.0
kbuild test robot
build botRe: [PATCH 6/6] scsi: qedf: use correct strncpy() size
I love your patch! Perhaps something to improve:
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->shost_gendev.kobj, KOBJ_CHANGE, envp);
173 }
174
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH 6/6] scsi: qedf: use correct strncpy() size
In reply to Arnd BergmannQuoted 6 lines · Arnd Bergmann
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=]
Quoted 8 lines
This changes it to
strscpy()with the correct length, guaranteeing a properly nul-terminated string of the right size.Signed-off-by Arnd Bergmann <[email protected]>--- drivers/scsi/qedf/qedf_dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reasonable security precaution.
Martin K. Petersen
AppliedRe: [PATCH 6/6] scsi: qedf: use correct strncpy() size
In reply to Arnd BergmannArnd,
Quoted 2 lines
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!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering