aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 929b58004b7e..b9f1c144b7a1 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -45,6 +45,7 @@
45#include <linux/proc_fs.h> 45#include <linux/proc_fs.h>
46#include <linux/mount.h> 46#include <linux/mount.h>
47#include <linux/security.h> 47#include <linux/security.h>
48#include <linux/ima.h>
48#include <linux/syscalls.h> 49#include <linux/syscalls.h>
49#include <linux/tsacct_kern.h> 50#include <linux/tsacct_kern.h>
50#include <linux/cn_proc.h> 51#include <linux/cn_proc.h>
@@ -127,6 +128,9 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
127 MAY_READ | MAY_EXEC | MAY_OPEN); 128 MAY_READ | MAY_EXEC | MAY_OPEN);
128 if (error) 129 if (error)
129 goto exit; 130 goto exit;
131 error = ima_path_check(&nd.path, MAY_READ | MAY_EXEC | MAY_OPEN);
132 if (error)
133 goto exit;
130 134
131 file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); 135 file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
132 error = PTR_ERR(file); 136 error = PTR_ERR(file);
@@ -674,6 +678,9 @@ struct file *open_exec(const char *name)
674 err = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_OPEN); 678 err = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_OPEN);
675 if (err) 679 if (err)
676 goto out_path_put; 680 goto out_path_put;
681 err = ima_path_check(&nd.path, MAY_EXEC | MAY_OPEN);
682 if (err)
683 goto out_path_put;
677 684
678 file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); 685 file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
679 if (IS_ERR(file)) 686 if (IS_ERR(file))
@@ -1184,6 +1191,9 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
1184 retval = security_bprm_check(bprm); 1191 retval = security_bprm_check(bprm);
1185 if (retval) 1192 if (retval)
1186 return retval; 1193 return retval;
1194 retval = ima_bprm_check(bprm);
1195 if (retval)
1196 return retval;
1187 1197
1188 /* kernel module loader fixup */ 1198 /* kernel module loader fixup */
1189 /* so we don't try to load run modprobe in kernel space. */ 1199 /* so we don't try to load run modprobe in kernel space. */
@@ -1284,6 +1294,7 @@ int do_execve(char * filename,
1284 retval = mutex_lock_interruptible(&current->cred_exec_mutex); 1294 retval = mutex_lock_interruptible(&current->cred_exec_mutex);
1285 if (retval < 0) 1295 if (retval < 0)
1286 goto out_free; 1296 goto out_free;
1297 current->in_execve = 1;
1287 1298
1288 retval = -ENOMEM; 1299 retval = -ENOMEM;
1289 bprm->cred = prepare_exec_creds(); 1300 bprm->cred = prepare_exec_creds();
@@ -1337,6 +1348,7 @@ int do_execve(char * filename,
1337 goto out; 1348 goto out;
1338 1349
1339 /* execve succeeded */ 1350 /* execve succeeded */
1351 current->in_execve = 0;
1340 mutex_unlock(&current->cred_exec_mutex); 1352 mutex_unlock(&current->cred_exec_mutex);
1341 acct_update_integrals(current); 1353 acct_update_integrals(current);
1342 free_bprm(bprm); 1354 free_bprm(bprm);
@@ -1355,6 +1367,7 @@ out_file:
1355 } 1367 }
1356 1368
1357out_unlock: 1369out_unlock:
1370 current->in_execve = 0;
1358 mutex_unlock(&current->cred_exec_mutex); 1371 mutex_unlock(&current->cred_exec_mutex);
1359 1372
1360out_free: 1373out_free: