diff options
author | Kees Cook <[email protected]> | 2017-05-05 15:42:55 -0700 |
---|---|---|
committer | Martin K. Petersen <[email protected]> | 2017-05-08 22:07:48 -0400 |
commit | cd22874fec8fbecd4999b55e67baf3d71775f6f3 (patch) | |
tree | 0e02757aef2592f535c754271fd7b441d9056dee | |
parent | 0d2fc3b48ba0e267962c861c5258564c335dd1f2 (diff) |
scsi: qedf: Avoid reading past end of buffer
Using memcpy() from a string that is shorter than the length copied
means the destination buffer is being filled with arbitrary data from
the kernel rodata segment. Instead, use strncpy() which will fill the
trailing bytes with zeros.
This was found with the future CONFIG_FORTIFY_SOURCE feature.
Cc: Daniel Micay <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
Acked-by: Chad Dupuis <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
-rw-r--r-- | drivers/scsi/qedf/qedf_main.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index cceddd995a4b..a5c97342fd5d 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -2895,7 +2895,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode) slowpath_params.drv_minor = QEDF_DRIVER_MINOR_VER; slowpath_params.drv_rev = QEDF_DRIVER_REV_VER; slowpath_params.drv_eng = QEDF_DRIVER_ENG_VER; - memcpy(slowpath_params.name, "qedf", QED_DRV_VER_STR_SIZE); + strncpy(slowpath_params.name, "qedf", QED_DRV_VER_STR_SIZE); rc = qed_ops->common->slowpath_start(qedf->cdev, &slowpath_params); if (rc) { QEDF_ERR(&(qedf->dbg_ctx), "Cannot start slowpath.\n"); |