diff options
author | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2015-12-28 16:02:29 -0500 |
---|---|---|
committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2016-02-18 17:14:03 -0500 |
commit | b44a7dfc6fa16e01f2497c9fa62c3926f94be174 (patch) | |
tree | b48ced5b7c84986778ca4ac3b6bf3f13c74f2ef2 /security | |
parent | 4b2530d819e179ae3352c38a1ceff929a922d070 (diff) |
vfs: define a generic function to read a file from the kernel
For a while it was looked down upon to directly read files from Linux.
These days there exists a few mechanisms in the kernel that do just
this though to load a file into a local buffer. There are minor but
important checks differences on each. This patch set is the first
attempt at resolving some of these differences.
This patch introduces a common function for reading files from the kernel
with the corresponding security post-read hook and function.
Changelog v4+:
- export security_kernel_post_read_file() - Fengguang Wu
v3:
- additional bounds checking - Luis
v2:
- To simplify patch review, re-ordered patches
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Reviewed-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security')
-rw-r--r-- | security/security.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/security/security.c b/security/security.c index e8ffd92ae2eb..c98dd6bf4ebd 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -910,6 +910,12 @@ int security_kernel_module_from_file(struct file *file) | |||
910 | return ima_module_check(file); | 910 | return ima_module_check(file); |
911 | } | 911 | } |
912 | 912 | ||
913 | int security_kernel_post_read_file(struct file *file, char *buf, loff_t size) | ||
914 | { | ||
915 | return call_int_hook(kernel_post_read_file, 0, file, buf, size); | ||
916 | } | ||
917 | EXPORT_SYMBOL_GPL(security_kernel_post_read_file); | ||
918 | |||
913 | int security_task_fix_setuid(struct cred *new, const struct cred *old, | 919 | int security_task_fix_setuid(struct cred *new, const struct cred *old, |
914 | int flags) | 920 | int flags) |
915 | { | 921 | { |
@@ -1697,6 +1703,8 @@ struct security_hook_heads security_hook_heads = { | |||
1697 | LIST_HEAD_INIT(security_hook_heads.kernel_module_request), | 1703 | LIST_HEAD_INIT(security_hook_heads.kernel_module_request), |
1698 | .kernel_module_from_file = | 1704 | .kernel_module_from_file = |
1699 | LIST_HEAD_INIT(security_hook_heads.kernel_module_from_file), | 1705 | LIST_HEAD_INIT(security_hook_heads.kernel_module_from_file), |
1706 | .kernel_post_read_file = | ||
1707 | LIST_HEAD_INIT(security_hook_heads.kernel_post_read_file), | ||
1700 | .task_fix_setuid = | 1708 | .task_fix_setuid = |
1701 | LIST_HEAD_INIT(security_hook_heads.task_fix_setuid), | 1709 | LIST_HEAD_INIT(security_hook_heads.task_fix_setuid), |
1702 | .task_setpgid = LIST_HEAD_INIT(security_hook_heads.task_setpgid), | 1710 | .task_setpgid = LIST_HEAD_INIT(security_hook_heads.task_setpgid), |