Skip to contentSkip to conversation

eeprom: at24: make spd world-readable again

PATCH Applied Jean Delvare 2 participants 4 messages Jul 28, 2019

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

PATCH v2 1/2 eeprom: at24: make spd world-readable again

The integration of the at24 driver into the nvmem framework broke the world-readability of spd EEPROMs. Fix it.

Fixes 57d155506dd5 ("eeprom: at24: extend driver to plug into the NVMEM framework")
Cc Andrew Lunn <[email protected]>
Cc Srinivas Kandagatla <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Arnd Bergmann <[email protected]>

---
Note: This is only the 1st half of the fix, the nvmem core driver also needs to be fixed.

Changes since V1:
* Split into 2 patches, one to the at24 driver and one to the nvmem core.

 drivers/misc/eeprom/at24.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/eeprom/at24.c +1 -1
@@ -719,7 +719,7 @@ static int at24_probe(struct i2c_client
 	nvmem_config.name = dev_name(dev);
 	nvmem_config.dev = dev;
 	nvmem_config.read_only = !writable;
-	nvmem_config.root_only = true;
+	nvmem_config.root_only = !(flags & AT24_FLAG_IRUGO);
 	nvmem_config.owner = THIS_MODULE;
 	nvmem_config.compat = true;
 	nvmem_config.base_dev = dev;
Signature · 2 lines
Jean Delvare
SUSE L3 Support
#1 lore raw

PATCH v2 2/2 nvmem: Use the same permissions for eeprom as for nvmem

The compatibility "eeprom" attribute is currently root-only no matter what the configuration says. The "nvmem" attribute does respect the setting of the root_only configuration bit, so do the same for "eeprom".

Fixes b6c217ab9be6 ("nvmem: Add backwards compatibility support for older EEPROM drivers.")
Cc Andrew Lunn <[email protected]>
Cc Srinivas Kandagatla <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Arnd Bergmann <[email protected]>

---
Changes since V1:
* Split into 2 patches, one to the at24 driver and one to the nvmem

   core. drivers/nvmem/nvmem-sysfs.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/nvmem/nvmem-sysfs.c +11 -4
@@ -224,10 +224,17 @@ int nvmem_sysfs_setup_compat(struct nvme
 	if (!config->base_dev)
 		return -EINVAL;
 
-	if (nvmem->read_only)
-		nvmem->eeprom = bin_attr_ro_root_nvmem;
-	else
-		nvmem->eeprom = bin_attr_rw_root_nvmem;
+	if (nvmem->read_only) {
+		if (config->root_only)
+			nvmem->eeprom = bin_attr_ro_root_nvmem;
+		else
+			nvmem->eeprom = bin_attr_ro_nvmem;
+	} else {
+		if (config->root_only)
+			nvmem->eeprom = bin_attr_rw_root_nvmem;
+		else
+			nvmem->eeprom = bin_attr_rw_nvmem;
+	}
 	nvmem->eeprom.attr.name = "eeprom";
 	nvmem->eeprom.size = nvmem->size;
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
Signature · 2 lines
Jean Delvare
SUSE L3 Support
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] nvmem: Use the same permissions for eeprom as for nvmem

niedz., 28 lip 2019 o 18:43 Jean Delvare <[email protected]> napisał(a):

Quoted 47 lines

The compatibility "eeprom" attribute is currently root-only no matter what the configuration says. The "nvmem" attribute does respect the setting of the root_only configuration bit, so do the same for "eeprom".

Fixes b6c217ab9be6 ("nvmem: Add backwards compatibility support for older EEPROM drivers.")
Cc Andrew Lunn <[email protected]>
Cc Srinivas Kandagatla <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Arnd Bergmann <[email protected]>

---
Changes since V1:
* Split into 2 patches, one to the at24 driver and one to the nvmem

   core. drivers/nvmem/nvmem-sysfs.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/nvmem/nvmem-sysfs.c 2019-07-28 18:06:53.105140893 +0200 renamed from drivers/nvmem/nvmem-sysfs.c 2019-07-08 00:41:56.000000000 +0200 +11 -5
@@ -224,10 +224,17 @@ int nvmem_sysfs_setup_compat(struct nvme
        if (!config->base_dev)
                return -EINVAL;
 
-       if (nvmem->read_only)
-               nvmem->eeprom = bin_attr_ro_root_nvmem;
-       else
-               nvmem->eeprom = bin_attr_rw_root_nvmem;
+       if (nvmem->read_only) {
+               if (config->root_only)
+                       nvmem->eeprom = bin_attr_ro_root_nvmem;
+               else
+                       nvmem->eeprom = bin_attr_ro_nvmem;
+       } else {
+               if (config->root_only)
+                       nvmem->eeprom = bin_attr_rw_root_nvmem;
+               else
+                       nvmem->eeprom = bin_attr_rw_nvmem;
+       }
        nvmem->eeprom.attr.name = "eeprom";
        nvmem->eeprom.size = nvmem->size;
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 
 
--
Quoted 2 lines

Jean Delvare
SUSE L3 Support

#3 lore raw
In reply to Jean Delvare

niedz., 28 lip 2019 o 18:41 Jean Delvare <[email protected]> napisał(a):

Quoted 36 lines

The integration of the at24 driver into the nvmem framework broke the world-readability of spd EEPROMs. Fix it.

Fixes 57d155506dd5 ("eeprom: at24: extend driver to plug into the NVMEM framework")
Cc Andrew Lunn <[email protected]>
Cc Srinivas Kandagatla <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Arnd Bergmann <[email protected]>

---
Note: This is only the 1st half of the fix, the nvmem core driver also needs to be fixed.

Changes since V1:
* Split into 2 patches, one to the at24 driver and one to the nvmem core.

 drivers/misc/eeprom/at24.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/eeprom/at24.c 2019-07-28 16:53:28.104167083 +0200 renamed from drivers/misc/eeprom/at24.c 2019-07-28 16:52:06.550918923 +0200 +1 -2
@@ -719,7 +719,7 @@ static int at24_probe(struct i2c_client
        nvmem_config.name = dev_name(dev);
        nvmem_config.dev = dev;
        nvmem_config.read_only = !writable;
-       nvmem_config.root_only = true;
+       nvmem_config.root_only = !(flags & AT24_FLAG_IRUGO);
        nvmem_config.owner = THIS_MODULE;
        nvmem_config.compat = true;
        nvmem_config.base_dev = dev;
 
 
--
Quoted 2 lines

Jean Delvare
SUSE L3 Support

Applied to fixes.

Bart