summaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
authorMimi Zohar <zohar@linux.vnet.ibm.com>2016-01-30 22:23:26 -0500
committerMimi Zohar <zohar@linux.vnet.ibm.com>2016-02-21 09:06:09 -0500
commit39eeb4fb97f60dbdfc823c1a673a8844b9226b60 (patch)
tree46e37e2211017237abd363a0dd1b3737da741ed0 /fs/exec.c
parente40ba6d56b41754b37b995dbc8035b2b3a6afd8a (diff)
downloadlinux-39eeb4fb97f60dbdfc823c1a673a8844b9226b60.tar.gz
linux-39eeb4fb97f60dbdfc823c1a673a8844b9226b60.tar.bz2
linux-39eeb4fb97f60dbdfc823c1a673a8844b9226b60.zip
security: define kernel_read_file hook
The kernel_read_file security hook is called prior to reading the file into memory. Changelog v4+: - export security_kernel_read_file() Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com> Acked-by: Kees Cook <keescook@chromium.org> Acked-by: Luis R. Rodriguez <mcgrof@kernel.org> Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 64cb3bc788c1..8aaa38666119 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -842,6 +842,10 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size,
if (!S_ISREG(file_inode(file)->i_mode) || max_size < 0)
return -EINVAL;
+ ret = security_kernel_read_file(file, id);
+ if (ret)
+ return ret;
+
i_size = i_size_read(file_inode(file));
if (max_size > 0 && i_size > max_size)
return -EFBIG;