| // SPDX-License-Identifier: GPL-2.0-or-later |
| /* Function to determine if a thread group is single threaded or not |
| * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. |
| * Written by David Howells (dhowells@redhat.com) |
| * - Derived from security/selinux/hooks.c |
| #include <linux/sched/signal.h> |
| #include <linux/sched/task.h> |
| #include <linux/sched/mm.h> |
| * Returns true if the task does not share ->mm with another thread/process. |
| bool current_is_single_threaded(void) |
| struct task_struct *task = current; |
| struct mm_struct *mm = task->mm; |
| struct task_struct *p, *t; |
| if (atomic_read(&task->signal->live) != 1) |
| if (atomic_read(&mm->mm_users) == 1) |
| if (unlikely(p->flags & PF_KTHREAD)) |
| if (unlikely(p == task->group_leader)) |
| if (unlikely(t->mm == mm)) |
| * t->mm == NULL. Make sure next_thread/next_task |
| * will see other CLONE_VM tasks which might be |