All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch added to 3.12-stable] ipr: Fix out-of-bounds null overwrite
@ 2016-03-30 14:25 Jiri Slaby
  2016-03-30 14:25 ` [patch added to 3.12-stable] ipr: Fix regression when loading firmware Jiri Slaby
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Jiri Slaby @ 2016-03-30 14:25 UTC (permalink / raw)
  To: stable; +Cc: Insu Yun, Martin K . Petersen, Ben Hutchings, Jiri Slaby

From: Insu Yun <wuninsu@gmail.com>

This patch has been added to the 3.12 stable tree. If you have any
objections, please let us know.

===============

commit d63c7dd5bcb9441af0526d370c43a65ca2c980d9 upstream.

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>
Reviewed-by: Shane Seymour <shane.seymour@hpe.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 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 0f6412db121c..4fa12a4467d2 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -3946,13 +3946,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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-03-30 16:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-30 14:25 [patch added to 3.12-stable] ipr: Fix out-of-bounds null overwrite Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] ipr: Fix regression when loading firmware Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] ipv4: Don't do expensive useless work during inetdev destroy Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] umount: Do not allow unmounting rootfs Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] kernel: Provide READ_ONCE and ASSIGN_ONCE Jiri Slaby
2016-03-30 16:33   ` Christian Borntraeger
2016-03-30 14:25 ` [patch added to 3.12-stable] xen: Add RING_COPY_REQUEST() Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] xen-netback: don't use last request to determine minimum Tx credit Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] xen-netback: use RING_COPY_REQUEST() throughout Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] xen-blkback: only read request operation from shared ring once Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] xen-blkback: read from indirect descriptors only once Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] xen/pciback: Save xen_pci_op commands before processing it Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] xen/pciback: Save the number of MSI-X entries to be copied later Jiri Slaby
2016-03-30 14:25 ` [patch added to 3.12-stable] xfs: allow inode allocations in post-growfs disk space Jiri Slaby

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.