Skip to contentSkip to conversation

acpi/ec: Deny write access unless requested by module param

PATCH Applied [email protected] 3 participants 3 messages Feb 6, 2016 – Mar 10, 2016 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpi/ec: Deny write access unless requested by module param

From: Oleg Drokin <[email protected]>

In debugfs it's not enough to just set file mode to read-only to deny write access to a file, instead just don't provide the write method unless write access is really requested.

---
I assume allowing run-time changes via /sys/module is preferrable, opposed to forced module unload and reload to change this option, but I can submit another patch to only depend on the module parameter too, please let me know.

 drivers/acpi/ec_sys.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/acpi/ec_sys.c +3 -0
index bea8e42..6c7dd7a 100644
@@ -73,6 +73,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
 	loff_t init_off = *off;
 	int err = 0;
 
+	if (!write_support)
+		return -EINVAL;
+
 	if (*off >= EC_SPACE_SIZE)
 		return 0;
 	if (*off + count >= EC_SPACE_SIZE) {
Signature · 1 line
2.1.0
#1 lore raw
Quoted 7 lines · On Saturday, February 06, 2016 02:08:08 AM [email protected] wrote:

From: Oleg Drokin <[email protected]>

In debugfs it's not enough to just set file mode to read-only to deny write access to a file, instead just don't provide the write method unless write access is really requested.

Thanks!

Quoted 23 lines

---
I assume allowing run-time changes via /sys/module is preferrable, opposed to forced module unload and reload to change this option, but I can submit another patch to only depend on the module parameter too, please let me know.

 drivers/acpi/ec_sys.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/acpi/ec_sys.c +3 -0
index bea8e42..6c7dd7a 100644
@@ -73,6 +73,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char
 __user *buf, loff_t init_off = *off;
 	int err = 0;
 
+	if (!write_support)
+		return -EINVAL;
+
 	if (*off >= EC_SPACE_SIZE)
 		return 0;
 	if (*off + count >= EC_SPACE_SIZE) {
#2 lore raw
In reply to [email protected]
Quoted 22 lines · On Saturday, February 06, 2016 02:08:08 AM [email protected] wrote:

From: Oleg Drokin <[email protected]>

In debugfs it's not enough to just set file mode to read-only to deny write access to a file, instead just don't provide the write method unless write access is really requested.

---
I assume allowing run-time changes via /sys/module is preferrable, opposed to forced module unload and reload to change this option, but I can submit another patch to only depend on the module parameter too, please let me know.

 drivers/acpi/ec_sys.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/acpi/ec_sys.c +0 -0
index bea8e42..6c7dd7a 100644

drivers/acpi/ec_sys.c static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf, · line 81

Quoted 9 lines
drivers/acpi/ec_sys.c +3 -0
@@ -73,6 +73,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
 	loff_t init_off = *off;
 	int err = 0;
 
+	if (!write_support)
+		return -EINVAL;
+
 	if (*off >= EC_SPACE_SIZE)
 		return 0;
 	if (*off + count >= EC_SPACE_SIZE) {

Applied, thanks!

Rafael