[PATCH] ACPI: Only allow users with CAP_SYS_RAWIO rights to overwrite ACPI funcs at runtime

From: Thomas Renninger
Date: Tue Sep 25 2012 - 11:29:18 EST


ACPI: Only allow users with CAP_SYS_RAWIO rights to overwrite ACPI funcs at runtime

and tab align file_operations callbacks.

Signed-off-by: Thomas Renninger <trenn@xxxxxxx>
---
drivers/acpi/custom_method.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index 5d42c24..9a0294d 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -72,9 +72,15 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
return count;
}

+static int open_check_acc(struct inode *inode, struct file *filp)
+{
+ return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
+}
+
static const struct file_operations cm_fops = {
- .write = cm_write,
- .llseek = default_llseek,
+ .write = cm_write,
+ .llseek = default_llseek,
+ .open = open_check_acc,
};

static int __init acpi_custom_method_init(void)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/