Skip to contentSkip to conversation

nvmem: core: Check read_only flag for force_ro in bin_attr_nvmem_write()

PATCH In review Marek Vasut 2 participants 5 messages Jul 13, 2024 – Oct 26, 2024

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

PATCH 1/1 nvmem: core: Check read_only flag for force_ro in bin_attr_nvmem_write()

The bin_attr_nvmem_write() must check the read_only flag and block writes on read-only devices, now that a nvmem device can be switched between read-write and read-only mode at runtime using the force_ro attribute. Add the missing check.

Fixes 9d7eb234ac7a ("nvmem: core: Implement force_ro sysfs attribute")

---
Cc: Srinivas Kandagatla <[email protected]>
Cc: [email protected]

---
 drivers/nvmem/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/core.c +1 -1
index 516dfd861b9f9..9cfe7d4bcda39 100644
@@ -267,7 +267,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
 
 	count = round_down(count, nvmem->word_size);
 
-	if (!nvmem->reg_write)
+	if (!nvmem->reg_write || nvmem->read_only)
 		return -EPERM;
 
 	rc = nvmem_reg_write(nvmem, pos, buf, count);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 10 lines · Marek Vasut

The bin_attr_nvmem_write() must check the read_only flag and block writes on read-only devices, now that a nvmem device can be switched between read-write and read-only mode at runtime using the force_ro attribute. Add the missing check.

Fixes 9d7eb234ac7a ("nvmem: core: Implement force_ro sysfs attribute")

---
Cc: Srinivas Kandagatla <[email protected]>
Cc: [email protected]

It seems this bugfix is not even in next, any news ?

#2 lore raw
Quoted 6 lines · Marek Vasut
Quoted 5 lines · Marek Vasut

The bin_attr_nvmem_write() must check the read_only flag and block writes on read-only devices, now that a nvmem device can be switched between read-write and read-only mode at runtime using the force_ro attribute. Add the missing check.

Quoted 6 lines
Quoted 5 lines
Fixes 9d7eb234ac7a ("nvmem: core: Implement force_ro sysfs attribute")

---
Cc: Srinivas Kandagatla <[email protected]>
Cc: [email protected]

It seems this bugfix is not even in next, any news ?

This is still broken, bugfix is available for three months now, but not picked up. Any news?

#3 lore raw

Apologies, some how I missed this email.

Quoted 9 lines · Marek Vasut
Quoted 8 lines · Marek Vasut
Quoted 7 lines · Marek Vasut

The bin_attr_nvmem_write() must check the read_only flag and block writes on read-only devices, now that a nvmem device can be switched between read-write and read-only mode at runtime using the force_ro attribute. Add the missing check.

Fixes 9d7eb234ac7a ("nvmem: core: Implement force_ro sysfs attribute")

Applied with CC stable.

--srini

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

---
Cc: Srinivas Kandagatla <[email protected]>
Cc: [email protected]

It seems this bugfix is not even in next, any news ?

This is still broken, bugfix is available for three months now, but not picked up. Any news?

#4 lore raw
Quoted 1 line · Srinivas Kandagatla

Apologies, some how I missed this email.

No worries, the commit was still in my upstreaming queue, so I figured it was time to remind upstream about it.

Quoted 8 lines · Marek Vasut
Quoted 7 lines · Marek Vasut
Quoted 6 lines · Marek Vasut
Quoted 5 lines

The bin_attr_nvmem_write() must check the read_only flag and block writes on read-only devices, now that a nvmem device can be switched between read-write and read-only mode at runtime using the force_ro attribute. Add the missing check.

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Fixes 9d7eb234ac7a ("nvmem: core: Implement force_ro sysfs attribute")

Applied with CC stable.

Thank you !