diff options
author | Oleg Nesterov <oleg@redhat.com> | 2014-01-23 18:55:49 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-23 19:37:02 -0500 |
commit | 83f62a2eacb1d6945c78523f20e0c34b5d94913c (patch) | |
tree | e42b10740afd8489319388018fa1d6d10be22482 /fs/exec.c | |
parent | 68ce670b6e8edc30551862e7f6a306e45389e189 (diff) |
exec:check_unsafe_exec: use while_each_thread() rather than next_thread()
next_thread() should be avoided, change check_unsafe_exec() to use
while_each_thread().
Nobody except signal->curr_target actually needs next_thread-like code,
and we need to change (fix) this interface. This particular code is fine,
p == current. But in general the code like this can loop forever if p
exits and next_thread(t) can't reach the unhashed thread.
This also saves 32 bytes.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1243,10 +1243,11 @@ static int check_unsafe_exec(struct linux_binprm *bprm) | |||
1243 | if (current->no_new_privs) | 1243 | if (current->no_new_privs) |
1244 | bprm->unsafe |= LSM_UNSAFE_NO_NEW_PRIVS; | 1244 | bprm->unsafe |= LSM_UNSAFE_NO_NEW_PRIVS; |
1245 | 1245 | ||
1246 | t = p; | ||
1246 | n_fs = 1; | 1247 | n_fs = 1; |
1247 | spin_lock(&p->fs->lock); | 1248 | spin_lock(&p->fs->lock); |
1248 | rcu_read_lock(); | 1249 | rcu_read_lock(); |
1249 | for (t = next_thread(p); t != p; t = next_thread(t)) { | 1250 | while_each_thread(p, t) { |
1250 | if (t->fs == p->fs) | 1251 | if (t->fs == p->fs) |
1251 | n_fs++; | 1252 | n_fs++; |
1252 | } | 1253 | } |