Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1636779
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] scsi: qedf: Avoid reading past end of buffer |
| Date | 2017-05-06 00:50 +0200 |
| Message-ID | <tDUcV-80b-7@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
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 <danielmicay@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/scsi/qedf/qedf_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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");
--
2.7.4
--
Kees Cook
Pixel Security
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] scsi: qedf: Avoid reading past end of buffer Kees Cook <keescook@chromium.org> - 2017-05-06 00:50 +0200
Re: [PATCH] scsi: qedf: Avoid reading past end of buffer Bart Van Assche <Bart.VanAssche@sandisk.com> - 2017-05-06 01:10 +0200
Re: [PATCH] scsi: qedf: Avoid reading past end of buffer Kees Cook <keescook@chromium.org> - 2017-05-06 01:20 +0200
Re: [PATCH] scsi: qedf: Avoid reading past end of buffer "Martin K. Petersen" <martin.petersen@oracle.com> - 2017-05-09 04:10 +0200
csiph-web