Skip to contentSkip to conversation

thunderbolt: Correct access permissions for active NVM contents

PATCH In review Mika Westerberg 2 participants 2 messages Jun 29, 2017 – Jul 5, 2017 Thunderbolt driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thunderbolt: Correct access permissions for active NVM contents

Firmware upgrade tools that decide which NVM image should be uploaded to the Thunderbolt controller need to access active parts of the NVM even if they are not run as root. The information in active NVM is not considered security critical so we can use the default permissions set by the NVMem framework.

Writing the NVM image is still left as root only operation.

While there mark the active NVM as read-only in the filesystem.

---
Hi,

This applies on top of my Thunderbolt patches in Greg's char-misc-next branch.

Thanks.

 drivers/thunderbolt/switch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thunderbolt/switch.c +2 -1
index ab3e8f410444..40219a706309 100644
@@ -281,9 +281,11 @@ static struct nvmem_device *register_nvmem(struct tb_switch *sw, int id,
 	if (active) {
 		config.name = "nvm_active";
 		config.reg_read = tb_switch_nvm_read;
+		config.read_only = true;
 	} else {
 		config.name = "nvm_non_active";
 		config.reg_write = tb_switch_nvm_write;
+		config.root_only = true;
 	}
 
 	config.id = id;
@@ -292,7 +294,6 @@ static struct nvmem_device *register_nvmem(struct tb_switch *sw, int id,
 	config.size = size;
 	config.dev = &sw->dev;
 	config.owner = THIS_MODULE;
-	config.root_only = true;
 	config.priv = sw;
 
 	return nvmem_register(&config);
Signature · 1 line
2.11.0
maintainer
#1 lore raw
Quoted 6 lines · Mika Westerberg

Firmware upgrade tools that decide which NVM image should be uploaded to the Thunderbolt controller need to access active parts of the NVM even if they are not run as root. The information in active NVM is not considered security critical so we can use the default permissions set by the NVMem framework.

Quoted 6 lines

Writing the NVM image is still left as root only operation.

While there mark the active NVM as read-only in the filesystem.

Sorry for the late reply (I'm on vacation :P).

Quoted 38 lines

---
Hi,

This applies on top of my Thunderbolt patches in Greg's char-misc-next branch.

Thanks.

 drivers/thunderbolt/switch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thunderbolt/switch.c +2 -2
index ab3e8f410444..40219a706309 100644
@@ -281,9 +281,11 @@ static struct nvmem_device *register_nvmem(struct tb_switch *sw, int id,
        if (active) {
                config.name = "nvm_active";
                config.reg_read = tb_switch_nvm_read;
+               config.read_only = true;
        } else {
                config.name = "nvm_non_active";
                config.reg_write = tb_switch_nvm_write;
+               config.root_only = true;
        }
 
        config.id = id;
@@ -292,7 +294,6 @@ static struct nvmem_device *register_nvmem(struct tb_switch *sw, int id,
        config.size = size;
        config.dev = &sw->dev;
        config.owner = THIS_MODULE;
-       config.root_only = true;
        config.priv = sw;
 
        return nvmem_register(&config);
--

2.11.0