aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-04-29 08:46:59 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-29 08:47:05 -0400
commite7fd5d4b3d240f42c30a9e3d20a4689c4d3a795a (patch)
tree4ba588631dd8189a818a91c9e3976526071178b6 /fs/exec.c
parent1130b0296184bc21806225fd06d533515a99d2db (diff)
parent56a50adda49b2020156616c4eb15353e0f9ad7de (diff)
Merge branch 'linus' into perfcounters/core
Merge reason: This brach was on -rc1, refresh it to almost-rc4 to pick up the latest upstream fixes. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/fs/exec.c b/fs/exec.c
index bf47ed0278f..fe75dcff023 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1069,7 +1069,6 @@ EXPORT_SYMBOL(install_exec_creds);
1069int check_unsafe_exec(struct linux_binprm *bprm) 1069int check_unsafe_exec(struct linux_binprm *bprm)
1070{ 1070{
1071 struct task_struct *p = current, *t; 1071 struct task_struct *p = current, *t;
1072 unsigned long flags;
1073 unsigned n_fs; 1072 unsigned n_fs;
1074 int res = 0; 1073 int res = 0;
1075 1074
@@ -1077,21 +1076,22 @@ int check_unsafe_exec(struct linux_binprm *bprm)
1077 1076
1078 n_fs = 1; 1077 n_fs = 1;
1079 write_lock(&p->fs->lock); 1078 write_lock(&p->fs->lock);
1080 lock_task_sighand(p, &flags); 1079 rcu_read_lock();
1081 for (t = next_thread(p); t != p; t = next_thread(t)) { 1080 for (t = next_thread(p); t != p; t = next_thread(t)) {
1082 if (t->fs == p->fs) 1081 if (t->fs == p->fs)
1083 n_fs++; 1082 n_fs++;
1084 } 1083 }
1084 rcu_read_unlock();
1085 1085
1086 if (p->fs->users > n_fs) { 1086 if (p->fs->users > n_fs) {
1087 bprm->unsafe |= LSM_UNSAFE_SHARE; 1087 bprm->unsafe |= LSM_UNSAFE_SHARE;
1088 } else { 1088 } else {
1089 if (p->fs->in_exec) 1089 res = -EAGAIN;
1090 res = -EAGAIN; 1090 if (!p->fs->in_exec) {
1091 p->fs->in_exec = 1; 1091 p->fs->in_exec = 1;
1092 res = 1;
1093 }
1092 } 1094 }
1093
1094 unlock_task_sighand(p, &flags);
1095 write_unlock(&p->fs->lock); 1095 write_unlock(&p->fs->lock);
1096 1096
1097 return res; 1097 return res;
@@ -1293,6 +1293,7 @@ int do_execve(char * filename,
1293 struct linux_binprm *bprm; 1293 struct linux_binprm *bprm;
1294 struct file *file; 1294 struct file *file;
1295 struct files_struct *displaced; 1295 struct files_struct *displaced;
1296 bool clear_in_exec;
1296 int retval; 1297 int retval;
1297 1298
1298 retval = unshare_files(&displaced); 1299 retval = unshare_files(&displaced);
@@ -1315,8 +1316,9 @@ int do_execve(char * filename,
1315 goto out_unlock; 1316 goto out_unlock;
1316 1317
1317 retval = check_unsafe_exec(bprm); 1318 retval = check_unsafe_exec(bprm);
1318 if (retval) 1319 if (retval < 0)
1319 goto out_unlock; 1320 goto out_unlock;
1321 clear_in_exec = retval;
1320 1322
1321 file = open_exec(filename); 1323 file = open_exec(filename);
1322 retval = PTR_ERR(file); 1324 retval = PTR_ERR(file);
@@ -1364,9 +1366,7 @@ int do_execve(char * filename,
1364 goto out; 1366 goto out;
1365 1367
1366 /* execve succeeded */ 1368 /* execve succeeded */
1367 write_lock(&current->fs->lock);
1368 current->fs->in_exec = 0; 1369 current->fs->in_exec = 0;
1369 write_unlock(&current->fs->lock);
1370 current->in_execve = 0; 1370 current->in_execve = 0;
1371 mutex_unlock(&current->cred_exec_mutex); 1371 mutex_unlock(&current->cred_exec_mutex);
1372 acct_update_integrals(current); 1372 acct_update_integrals(current);
@@ -1386,9 +1386,8 @@ out_file:
1386 } 1386 }
1387 1387
1388out_unmark: 1388out_unmark:
1389 write_lock(&current->fs->lock); 1389 if (clear_in_exec)
1390 current->fs->in_exec = 0; 1390 current->fs->in_exec = 0;
1391 write_unlock(&current->fs->lock);
1392 1391
1393out_unlock: 1392out_unlock:
1394 current->in_execve = 0; 1393 current->in_execve = 0;