projects
/
cascardo
/
linux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[cascardo/linux.git]
/
security
/
selinux
/
selinuxfs.c
diff --git
a/security/selinux/selinuxfs.c
b/security/selinux/selinuxfs.c
index
0dc407d
..
732c1c7
100644
(file)
--- a/
security/selinux/selinuxfs.c
+++ b/
security/selinux/selinuxfs.c
@@
-148,23
+148,16
@@
static ssize_t sel_write_enforce(struct file *file, const char __user *buf,
ssize_t length;
int new_value;
ssize_t length;
int new_value;
- length = -ENOMEM;
if (count >= PAGE_SIZE)
if (count >= PAGE_SIZE)
-
goto out
;
+
return -ENOMEM
;
/* No partial writes. */
/* No partial writes. */
- length = -EINVAL;
if (*ppos != 0)
if (*ppos != 0)
- goto out;
-
- length = -ENOMEM;
- page = (char *)get_zeroed_page(GFP_KERNEL);
- if (!page)
- goto out;
+ return -EINVAL;
-
length = -EFAULT
;
- if (
copy_from_user(page, buf, count
))
-
goto out
;
+
page = memdup_user_nul(buf, count)
;
+ if (
IS_ERR(page
))
+
return PTR_ERR(page)
;
length = -EINVAL;
if (sscanf(page, "%d", &new_value) != 1)
length = -EINVAL;
if (sscanf(page, "%d", &new_value) != 1)
@@
-187,7
+180,7
@@
static ssize_t sel_write_enforce(struct file *file, const char __user *buf,
}
length = count;
out:
}
length = count;
out:
-
free_page((unsigned long)
page);
+
kfree(
page);
return length;
}
#else
return length;
}
#else
@@
-276,27
+269,20
@@
static ssize_t sel_write_disable(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
size_t count, loff_t *ppos)
{
- char *page
= NULL
;
+ char *page;
ssize_t length;
int new_value;
ssize_t length;
int new_value;
- length = -ENOMEM;
if (count >= PAGE_SIZE)
if (count >= PAGE_SIZE)
-
goto out
;
+
return -ENOMEM
;
/* No partial writes. */
/* No partial writes. */
- length = -EINVAL;
if (*ppos != 0)
if (*ppos != 0)
- goto out;
-
- length = -ENOMEM;
- page = (char *)get_zeroed_page(GFP_KERNEL);
- if (!page)
- goto out;
+ return -EINVAL;
-
length = -EFAULT
;
- if (
copy_from_user(page, buf, count
))
-
goto out
;
+
page = memdup_user_nul(buf, count)
;
+ if (
IS_ERR(page
))
+
return PTR_ERR(page)
;
length = -EINVAL;
if (sscanf(page, "%d", &new_value) != 1)
length = -EINVAL;
if (sscanf(page, "%d", &new_value) != 1)
@@
-314,7
+300,7
@@
static ssize_t sel_write_disable(struct file *file, const char __user *buf,
length = count;
out:
length = count;
out:
-
free_page((unsigned long)
page);
+
kfree(
page);
return length;
}
#else
return length;
}
#else
@@
-612,31
+598,24
@@
static ssize_t sel_read_checkreqprot(struct file *filp, char __user *buf,
static ssize_t sel_write_checkreqprot(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
static ssize_t sel_write_checkreqprot(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
- char *page
= NULL
;
+ char *page;
ssize_t length;
unsigned int new_value;
length = task_has_security(current, SECURITY__SETCHECKREQPROT);
if (length)
ssize_t length;
unsigned int new_value;
length = task_has_security(current, SECURITY__SETCHECKREQPROT);
if (length)
-
goto out
;
+
return length
;
- length = -ENOMEM;
if (count >= PAGE_SIZE)
if (count >= PAGE_SIZE)
-
goto out
;
+
return -ENOMEM
;
/* No partial writes. */
/* No partial writes. */
- length = -EINVAL;
if (*ppos != 0)
if (*ppos != 0)
- goto out;
-
- length = -ENOMEM;
- page = (char *)get_zeroed_page(GFP_KERNEL);
- if (!page)
- goto out;
+ return -EINVAL;
-
length = -EFAULT
;
- if (
copy_from_user(page, buf, count
))
-
goto out
;
+
page = memdup_user_nul(buf, count)
;
+ if (
IS_ERR(page
))
+
return PTR_ERR(page)
;
length = -EINVAL;
if (sscanf(page, "%u", &new_value) != 1)
length = -EINVAL;
if (sscanf(page, "%u", &new_value) != 1)
@@
-645,7
+624,7
@@
static ssize_t sel_write_checkreqprot(struct file *file, const char __user *buf,
selinux_checkreqprot = new_value ? 1 : 0;
length = count;
out:
selinux_checkreqprot = new_value ? 1 : 0;
length = count;
out:
-
free_page((unsigned long)
page);
+
kfree(
page);
return length;
}
static const struct file_operations sel_checkreqprot_ops = {
return length;
}
static const struct file_operations sel_checkreqprot_ops = {
@@
-1178,14
+1157,12
@@
static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
if (*ppos != 0)
goto out;
if (*ppos != 0)
goto out;
- length = -ENOMEM;
- page = (char *)get_zeroed_page(GFP_KERNEL);
- if (!page)
- goto out;
-
- length = -EFAULT;
- if (copy_from_user(page, buf, count))
+ page = memdup_user_nul(buf, count);
+ if (IS_ERR(page)) {
+ length = PTR_ERR(page);
+ page = NULL;
goto out;
goto out;
+ }
length = -EINVAL;
if (sscanf(page, "%d", &new_value) != 1)
length = -EINVAL;
if (sscanf(page, "%d", &new_value) != 1)
@@
-1199,7
+1176,7
@@
static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
out:
mutex_unlock(&sel_mutex);
out:
mutex_unlock(&sel_mutex);
-
free_page((unsigned long)
page);
+
kfree(
page);
return length;
}
return length;
}
@@
-1232,14
+1209,12
@@
static ssize_t sel_commit_bools_write(struct file *filep,
if (*ppos != 0)
goto out;
if (*ppos != 0)
goto out;
- length = -ENOMEM;
- page = (char *)get_zeroed_page(GFP_KERNEL);
- if (!page)
- goto out;
-
- length = -EFAULT;
- if (copy_from_user(page, buf, count))
+ page = memdup_user_nul(buf, count);
+ if (IS_ERR(page)) {
+ length = PTR_ERR(page);
+ page = NULL;
goto out;
goto out;
+ }
length = -EINVAL;
if (sscanf(page, "%d", &new_value) != 1)
length = -EINVAL;
if (sscanf(page, "%d", &new_value) != 1)
@@
-1254,7
+1229,7
@@
static ssize_t sel_commit_bools_write(struct file *filep,
out:
mutex_unlock(&sel_mutex);
out:
mutex_unlock(&sel_mutex);
-
free_page((unsigned long)
page);
+
kfree(
page);
return length;
}
return length;
}
@@
-1370,31
+1345,24
@@
static ssize_t sel_write_avc_cache_threshold(struct file *file,
size_t count, loff_t *ppos)
{
size_t count, loff_t *ppos)
{
- char *page
= NULL
;
+ char *page;
ssize_t ret;
int new_value;
ret = task_has_security(current, SECURITY__SETSECPARAM);
if (ret)
ssize_t ret;
int new_value;
ret = task_has_security(current, SECURITY__SETSECPARAM);
if (ret)
-
goto ou
t;
+
return re
t;
- ret = -ENOMEM;
if (count >= PAGE_SIZE)
if (count >= PAGE_SIZE)
-
goto out
;
+
return -ENOMEM
;
/* No partial writes. */
/* No partial writes. */
- ret = -EINVAL;
if (*ppos != 0)
if (*ppos != 0)
- goto out;
-
- ret = -ENOMEM;
- page = (char *)get_zeroed_page(GFP_KERNEL);
- if (!page)
- goto out;
+ return -EINVAL;
-
ret = -EFAULT
;
- if (
copy_from_user(page, buf, count
))
-
goto out
;
+
page = memdup_user_nul(buf, count)
;
+ if (
IS_ERR(page
))
+
return PTR_ERR(page)
;
ret = -EINVAL;
if (sscanf(page, "%u", &new_value) != 1)
ret = -EINVAL;
if (sscanf(page, "%u", &new_value) != 1)
@@
-1404,7
+1372,7
@@
static ssize_t sel_write_avc_cache_threshold(struct file *file,
ret = count;
out:
ret = count;
out:
-
free_page((unsigned long)
page);
+
kfree(
page);
return ret;
}
return ret;
}