Skip to contentSkip to conversation

PCI: sysfs: Update ROM to include default owner write access

PATCH Applied Alex Williamson 3 participants 3 messages Jan 5, 2011 – Jan 7, 2011 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: sysfs: Update ROM to include default owner write access

The PCI sysfs ROM interface requires an enabling write to access the ROM image, but the default file mode is 0400. The original proposed patch adding sysfs ROM support was a true read-only interface, with the enabling bit coming in as a feature request. I suspect it was simply an oversight that the file mode didn't get updated to match the API.

---

 drivers/pci/pci-sysfs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/pci/pci-sysfs.c +1 -1
index 63d5042..8ecaac9 100644
@@ -1149,7 +1149,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
 		sysfs_bin_attr_init(attr);
 		attr->size = rom_size;
 		attr->attr.name = "rom";
-		attr->attr.mode = S_IRUSR;
+		attr->attr.mode = S_IRUSR | S_IWUSR;
 		attr->read = pci_read_rom;
 		attr->write = pci_write_rom;
 		retval = sysfs_create_bin_file(&pdev->dev.kobj, attr);
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · * Alex Williamson ([email protected]) wrote:

The PCI sysfs ROM interface requires an enabling write to access the ROM image, but the default file mode is 0400. The original proposed patch adding sysfs ROM support was a true read-only interface, with the enabling bit coming in as a feature request. I suspect it was simply an oversight that the file mode didn't get updated to match the API.

This is often not an issue given normal root capabilities, but once we strip those capabilities, the default 0400 causes O_RDWR to fail. As Alex said, given the only way to use the file is to write to it first, making it writable makes sense.

Quoted 1 line
Applied
#2 lore raw
In reply to Alex Williamson
Quoted 18 lines · On Wed, 05 Jan 2011 10:26:41 -0700 Alex Williamson…

The PCI sysfs ROM interface requires an enabling write to access the ROM image, but the default file mode is 0400. The original proposed patch adding sysfs ROM support was a true read-only interface, with the enabling bit coming in as a feature request. I suspect it was simply an oversight that the file mode didn't get updated to match the API.

---

 drivers/pci/pci-sysfs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/pci/pci-sysfs.c +0 -0
index 63d5042..8ecaac9 100644

drivers/pci/pci-sysfs.c int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) · line 1155

Quoted 8 lines
drivers/pci/pci-sysfs.c +1 -1
@@ -1149,7 +1149,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
 		sysfs_bin_attr_init(attr);
 		attr->size = rom_size;
 		attr->attr.name = "rom";
-		attr->attr.mode = S_IRUSR;
+		attr->attr.mode = S_IRUSR | S_IWUSR;
 		attr->read = pci_read_rom;
 		attr->write = pci_write_rom;
 		retval = sysfs_create_bin_file(&pdev->dev.kobj, attr);

Applied, thanks.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center