* [PATCH v3] ipr: fix out-of-bounds null overwrite
@ 2016-01-06 17:44 Insu Yun
2016-01-07 10:19 ` Seymour, Shane M
2016-01-08 2:52 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Insu Yun @ 2016-01-06 17:44 UTC (permalink / raw)
To: brking, JBottomley, martin.petersen, linux-scsi, linux-kernel
Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun
Return value of snprintf is not bound by size value, 2nd argument.
(https://www.kernel.org/doc/htmldocs/kernel-api/API-snprintf.html).
Return value is number of printed chars, can be larger than 2nd argument.
Therefore, it can write null byte out of bounds ofbuffer.
Since snprintf puts null, it does not need to put additional null byte.
Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
drivers/scsi/ipr.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 536cd5a..1c3759b 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -4003,13 +4003,12 @@ static ssize_t ipr_store_update_fw(struct device *dev,
struct ipr_sglist *sglist;
char fname[100];
char *src;
- int len, result, dnld_size;
+ int result, dnld_size;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- len = snprintf(fname, 99, "%s", buf);
- fname[len-1] = '\0';
+ snprintf(fname, sizeof(fname), "%s", buf);
if (request_firmware(&fw_entry, fname, &ioa_cfg->pdev->dev)) {
dev_err(&ioa_cfg->pdev->dev, "Firmware file %s not found\n", fname);
--
1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v3] ipr: fix out-of-bounds null overwrite
2016-01-06 17:44 [PATCH v3] ipr: fix out-of-bounds null overwrite Insu Yun
@ 2016-01-07 10:19 ` Seymour, Shane M
2016-01-08 2:52 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Seymour, Shane M @ 2016-01-07 10:19 UTC (permalink / raw)
To: Insu Yun, brking, JBottomley, martin.petersen, linux-scsi, linux-kernel
Cc: taesoo, yeongjin.jang, insu, changwoo
> Signed-off-by: Insu Yun <wuninsu@gmail.com>
Thanks for making the changes.
Reviewed-by: Shane Seymour <shane.seymour@hpe.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] ipr: fix out-of-bounds null overwrite
2016-01-06 17:44 [PATCH v3] ipr: fix out-of-bounds null overwrite Insu Yun
2016-01-07 10:19 ` Seymour, Shane M
@ 2016-01-08 2:52 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2016-01-08 2:52 UTC (permalink / raw)
To: Insu Yun
Cc: brking, JBottomley, martin.petersen, linux-scsi, linux-kernel,
taesoo, yeongjin.jang, insu, changwoo, Shane Seymour
>>>>> "Insu" == Insu Yun <wuninsu@gmail.com> writes:
Insu> Return value of snprintf is not bound by size value, 2nd argument.
Insu> (https://www.kernel.org/doc/htmldocs/kernel-api/API-snprintf.html).
Insu> Return value is number of printed chars, can be larger than 2nd
Insu> argument. Therefore, it can write null byte out of bounds
Insu> ofbuffer. Since snprintf puts null, it does not need to put
Insu> additional null byte.
Applied to 4.5/scsi-queue.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-08 2:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-06 17:44 [PATCH v3] ipr: fix out-of-bounds null overwrite Insu Yun
2016-01-07 10:19 ` Seymour, Shane M
2016-01-08 2:52 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®