Commit 5bb459bb authored by Oleg Nesterov's avatar Oleg Nesterov Committed by James Morris

kernel: rename is_single_threaded(task) to current_is_single_threaded(void)

- 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: default avatarOleg Nesterov <oleg@redhat.com>
Acked-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent d2e3ee9b
...@@ -2075,7 +2075,7 @@ static inline unsigned long wait_task_inactive(struct task_struct *p, ...@@ -2075,7 +2075,7 @@ static inline unsigned long wait_task_inactive(struct task_struct *p,
#define for_each_process(p) \ #define for_each_process(p) \
for (p = &init_task ; (p = next_task(p)) != &init_task ; ) 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 * Careful: do_each_thread/while_each_thread is a double loop so
......
...@@ -15,8 +15,9 @@ ...@@ -15,8 +15,9 @@
/* /*
* Returns true if the task does not share ->mm with another thread/process. * 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 mm_struct *mm = task->mm;
struct task_struct *p, *t; struct task_struct *p, *t;
bool ret; bool ret;
......
...@@ -702,7 +702,7 @@ long join_session_keyring(const char *name) ...@@ -702,7 +702,7 @@ long join_session_keyring(const char *name)
/* only permit this if there's a single thread in the thread group - /* 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 * this avoids us having to adjust the creds on all threads and risking
* ENOMEM */ * ENOMEM */
if (!is_single_threaded(current)) if (!current_is_single_threaded())
return -EMLINK; return -EMLINK;
new = prepare_creds(); new = prepare_creds();
......
...@@ -5187,7 +5187,7 @@ static int selinux_setprocattr(struct task_struct *p, ...@@ -5187,7 +5187,7 @@ static int selinux_setprocattr(struct task_struct *p,
/* Only allow single threaded processes to change context */ /* Only allow single threaded processes to change context */
error = -EPERM; error = -EPERM;
if (!is_single_threaded(p)) { if (!current_is_single_threaded()) {
error = security_bounded_transition(tsec->sid, sid); error = security_bounded_transition(tsec->sid, sid);
if (error) if (error)
goto abort_change; goto abort_change;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment