kernel: rename is_single_threaded(task) to current_is_single_threaded(void)
authorOleg Nesterov <oleg@redhat.com>
Fri, 10 Jul 2009 01:48:23 +0000 (03:48 +0200)
committerJames Morris <jmorris@namei.org>
Thu, 16 Jul 2009 23:10:42 +0000 (09:10 +1000)
- is_single_threaded(task) is not safe unless task == current,
  we can't use task->signal or task->mm.

- it doesn't make sense unless task == current, the task can
  fork right after the check.

Rename it to current_is_single_threaded() and kill the argument.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
include/linux/sched.h
lib/is_single_threaded.c
security/keys/process_keys.c
security/selinux/hooks.c

index 16a982e389fb289560d13039bfb608fd82bbdae2..0839a2c9b952b5c91ba4279be597a13a3d7bee42 100644 (file)
@@ -2075,7 +2075,7 @@ static inline unsigned long wait_task_inactive(struct task_struct *p,
 #define for_each_process(p) \
        for (p = &init_task ; (p = next_task(p)) != &init_task ; )
 
-extern bool is_single_threaded(struct task_struct *);
+extern bool current_is_single_threaded(void);
 
 /*
  * Careful: do_each_thread/while_each_thread is a double loop so
index 2762516e0a5ee57ab1feceea4c096e85a59e0c47..434010980bdf9b3ae6b66f2982da1b5a92e20c47 100644 (file)
@@ -15,8 +15,9 @@
 /*
  * Returns true if the task does not share ->mm with another thread/process.
  */
-bool is_single_threaded(struct task_struct *task)
+bool current_is_single_threaded(void)
 {
+       struct task_struct *task = current;
        struct mm_struct *mm = task->mm;
        struct task_struct *p, *t;
        bool ret;
index 276d27882ce84394d7d6ce5b0c12d82e05f89987..ed929af466d358ee9fce44fb31346ce5fe2637e8 100644 (file)
@@ -702,7 +702,7 @@ long join_session_keyring(const char *name)
        /* only permit this if there's a single thread in the thread group -
         * this avoids us having to adjust the creds on all threads and risking
         * ENOMEM */
-       if (!is_single_threaded(current))
+       if (!current_is_single_threaded())
                return -EMLINK;
 
        new = prepare_creds();
index 2081055f6783a64c88ae412b1338f53a50d7777b..e65677da36bd6bbaafa31a6c011cf4b75a07fbd9 100644 (file)
@@ -5187,7 +5187,7 @@ static int selinux_setprocattr(struct task_struct *p,
 
                /* Only allow single threaded processes to change context */
                error = -EPERM;
-               if (!is_single_threaded(p)) {
+               if (!current_is_single_threaded()) {
                        error = security_bounded_transition(tsec->sid, sid);
                        if (error)
                                goto abort_change;