diff --git a/drivers/hyperhold/hp_core.c b/drivers/hyperhold/hp_core.c index a55ee05f3fe622120bcf6b7c9da5688d29a88e9d..bb844857c7c3ae45477dd50d00ca15ee9fdb3b7b 100644 --- a/drivers/hyperhold/hp_core.c +++ b/drivers/hyperhold/hp_core.c @@ -136,12 +136,21 @@ EXPORT_SYMBOL(hyperhold_enable); static int enable_sysctl_handler(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { + const struct cred *cred = current_cred(); + char *filter_buf; + + filter_buf = strstrip((char *)buffer); if (write) { - if (!strcmp(buffer, "enable\n")) + if (!uid_eq(cred->euid, GLOBAL_MEMMGR_UID) && + !uid_eq(cred->euid, GLOBAL_ROOT_UID)) { + pr_err("no permission to enable/disable eswap!\n"); + return 0; + } + if (!strcmp(filter_buf, "enable")) hyperhold_enable(); - else if (!strcmp(buffer, "disable\n")) + else if (!strcmp(filter_buf, "disable")) hyperhold_disable(false); - else if (!strcmp(buffer, "force_disable\n")) + else if (!strcmp(filter_buf, "force_disable")) hyperhold_disable(true); } else { if (*lenp < HP_STATE_LEN || *ppos) { @@ -225,7 +234,7 @@ static struct ctl_table_header *hp_sysctl_header; static struct ctl_table hp_table[] = { { .procname = "enable", - .mode = 0644, + .mode = 0666, .proc_handler = enable_sysctl_handler, }, {