Skip to contentSkip to conversation

ipr: Fix regression when loading firmware

PATCH Applied Gabriel Krisman Bertazi 4 participants 4 messages Feb 25, 2016 – Feb 26, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipr: Fix regression when loading firmware

Commit d63c7dd5bcb9 ("ipr: Fix out-of-bounds null overwrite") removed the end of line handling when storing the update_fw sysfs attribute. This changed the userpace API because it started refusing writes terminated by a line feed, which broke the update tools we already have.

This patch re-adds that handling, so both a write terminated by a line feed or not can make it through with the update.

Fixes d63c7dd5bcb9 ("ipr: Fix out-of-bounds null overwrite")
Cc Insu Yun <[email protected]>
---
 drivers/scsi/ipr.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/scsi/ipr.c +5 -0
index 3b3e099..d6a691e 100644
@@ -4002,6 +4002,7 @@ static ssize_t ipr_store_update_fw(struct device *dev,
 	struct ipr_sglist *sglist;
 	char fname[100];
 	char *src;
+	char *endline;
 	int result, dnld_size;
 
 	if (!capable(CAP_SYS_ADMIN))
@@ -4009,6 +4010,10 @@ static ssize_t ipr_store_update_fw(struct device *dev,
 
 	snprintf(fname, sizeof(fname), "%s", buf);
 
+	endline = strchr(fname, '\n');
+	if (endline)
+		*endline = '\0';
+
 	if (request_firmware(&fw_entry, fname, &ioa_cfg->pdev->dev)) {
 		dev_err(&ioa_cfg->pdev->dev, "Firmware file %s not found\n", fname);
 		return -EIO;
Signature · 1 line
2.1.0
Acked-by on v1 1/1
#1 lore raw
Quoted 29 lines · Gabriel Krisman Bertazi

Commit d63c7dd5bcb9 ("ipr: Fix out-of-bounds null overwrite") removed the end of line handling when storing the update_fw sysfs attribute. This changed the userpace API because it started refusing writes terminated by a line feed, which broke the update tools we already have.

This patch re-adds that handling, so both a write terminated by a line feed or not can make it through with the update.

Fixes d63c7dd5bcb9 ("ipr: Fix out-of-bounds null overwrite")
Cc Insu Yun <[email protected]>
---
 drivers/scsi/ipr.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/scsi/ipr.c +1 -0
index 3b3e099..d6a691e 100644
@@ -4002,6 +4002,7 @@ static ssize_t ipr_store_update_fw(struct device *dev,
 	struct ipr_sglist *sglist;
 	char fname[100];
 	char *src;
+	char *endline;
 	int result, dnld_size;
 
 	if (!capable(CAP_SYS_ADMIN))

drivers/scsi/ipr.c static ssize_t ipr_store_update_fw(struct device *dev, · line 4019

Quoted 10 lines
drivers/scsi/ipr.c +4 -0
@@ -4009,6 +4010,10 @@ static ssize_t ipr_store_update_fw(struct device *dev,
 
 	snprintf(fname, sizeof(fname), "%s", buf);
 
+	endline = strchr(fname, '\n');
+	if (endline)
+		*endline = '\0';
+
 	if (request_firmware(&fw_entry, fname, &ioa_cfg->pdev->dev)) {
 		dev_err(&ioa_cfg->pdev->dev, "Firmware file %s not found\n", fname);
 		return -EIO;

James - since this is a regression, can we get this fix in for 4.5 yet?

Thanks,

Brian

Signature · 3 lines
Brian King
Power Linux I/O
IBM Linux Technology Center
maintainer
#2 lore raw
Quoted 51 lines · Brian King
Quoted 44 lines · Gabriel Krisman Bertazi

Commit d63c7dd5bcb9 ("ipr: Fix out-of-bounds null overwrite") removed the
end of line handling when storing the update_fw sysfs attribute.
This
changed the userpace API because it started refusing writes terminated
by a line feed, which broke the update tools we already have.

This patch re-adds that handling, so both a write terminated by a line
feed or not can make it through with the update.

Fixes d63c7dd5bcb9 ("ipr: Fix out-of-bounds null overwrite")
Cc Insu Yun <[email protected]>
---
 drivers/scsi/ipr.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/scsi/ipr.c +1 -0
index 3b3e099..d6a691e 100644
@@ -4002,6 +4002,7 @@ static ssize_t ipr_store_update_fw(struct
 device *dev,
 	struct ipr_sglist *sglist;
 	char fname[100];
 	char *src;
+	char *endline;
 	int result, dnld_size;
 
drivers/scsi/ipr.c +4 -1
 	if (!capable(CAP_SYS_ADMIN))
@@ -4009,6 +4010,10 @@ static ssize_t ipr_store_update_fw(struct
 device *dev,
 
 	snprintf(fname, sizeof(fname), "%s", buf);
 
+	endline = strchr(fname, '\n');
+	if (endline)
+		*endline = '\0';
+
 	if (request_firmware(&fw_entry, fname, &ioa_cfg->pdev
->dev)) {
 		dev_err(&ioa_cfg->pdev->dev, "Firmware file %s not
Quoted 3 lines

found\n", fname);
return -EIO;

Quoted 2 lines

James - since this is a regression, can we get this fix in for 4.5 yet?

Yes, but in future, could you actually check patches in your driver before they get sent to Linus? This one went via the usual merge window process, so there was plenty of time to test it. We get a lot of these apparently innocuous minor bug fixes that actually contain a much more subtle bug. They're very difficult for reviewers to spot, but they do show up on hardware testing.

James

#3 lore raw
In reply to Gabriel Krisman Bertazi
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Gabriel" == Gabriel Krisman Bertazi <[email protected]> writes:

Gabriel> Commit d63c7dd5bcb9 ("ipr: Fix out-of-bounds null overwrite") Gabriel> removed the end of line handling when storing the update_fw Gabriel> sysfs attribute. This changed the userpace API because it Gabriel> started refusing writes terminated by a line feed, which broke Gabriel> the update tools we already have.

Gabriel> This patch re-adds that handling, so both a write terminated by Gabriel> a line feed or not can make it through with the update.

Applied to 4.5/scsi-fixes.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering