diff options
author | James Morris <jmorris@namei.org> | 2009-03-23 19:52:46 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2009-03-23 19:52:46 -0400 |
commit | 703a3cd72817e99201cef84a8a7aecc60b2b3581 (patch) | |
tree | 3e943755178ff410694722bb031f523136fbc432 /fs/exec.c | |
parent | df7f54c012b92ec93d56b68547351dcdf8a163d3 (diff) | |
parent | 8e0ee43bc2c3e19db56a4adaa9a9b04ce885cd84 (diff) |
Merge branch 'master' into next
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -1056,16 +1056,32 @@ EXPORT_SYMBOL(install_exec_creds); | |||
1056 | * - the caller must hold current->cred_exec_mutex to protect against | 1056 | * - the caller must hold current->cred_exec_mutex to protect against |
1057 | * PTRACE_ATTACH | 1057 | * PTRACE_ATTACH |
1058 | */ | 1058 | */ |
1059 | void check_unsafe_exec(struct linux_binprm *bprm) | 1059 | void check_unsafe_exec(struct linux_binprm *bprm, struct files_struct *files) |
1060 | { | 1060 | { |
1061 | struct task_struct *p = current; | 1061 | struct task_struct *p = current, *t; |
1062 | unsigned long flags; | ||
1063 | unsigned n_fs, n_files, n_sighand; | ||
1062 | 1064 | ||
1063 | bprm->unsafe = tracehook_unsafe_exec(p); | 1065 | bprm->unsafe = tracehook_unsafe_exec(p); |
1064 | 1066 | ||
1065 | if (atomic_read(&p->fs->count) > 1 || | 1067 | n_fs = 1; |
1066 | atomic_read(&p->files->count) > 1 || | 1068 | n_files = 1; |
1067 | atomic_read(&p->sighand->count) > 1) | 1069 | n_sighand = 1; |
1070 | lock_task_sighand(p, &flags); | ||
1071 | for (t = next_thread(p); t != p; t = next_thread(t)) { | ||
1072 | if (t->fs == p->fs) | ||
1073 | n_fs++; | ||
1074 | if (t->files == files) | ||
1075 | n_files++; | ||
1076 | n_sighand++; | ||
1077 | } | ||
1078 | |||
1079 | if (atomic_read(&p->fs->count) > n_fs || | ||
1080 | atomic_read(&p->files->count) > n_files || | ||
1081 | atomic_read(&p->sighand->count) > n_sighand) | ||
1068 | bprm->unsafe |= LSM_UNSAFE_SHARE; | 1082 | bprm->unsafe |= LSM_UNSAFE_SHARE; |
1083 | |||
1084 | unlock_task_sighand(p, &flags); | ||
1069 | } | 1085 | } |
1070 | 1086 | ||
1071 | /* | 1087 | /* |
@@ -1284,7 +1300,7 @@ int do_execve(char * filename, | |||
1284 | bprm->cred = prepare_exec_creds(); | 1300 | bprm->cred = prepare_exec_creds(); |
1285 | if (!bprm->cred) | 1301 | if (!bprm->cred) |
1286 | goto out_unlock; | 1302 | goto out_unlock; |
1287 | check_unsafe_exec(bprm); | 1303 | check_unsafe_exec(bprm, displaced); |
1288 | 1304 | ||
1289 | file = open_exec(filename); | 1305 | file = open_exec(filename); |
1290 | retval = PTR_ERR(file); | 1306 | retval = PTR_ERR(file); |