lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090331205703.GA21030@redhat.com>
Date:	Tue, 31 Mar 2009 22:57:03 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	David Howells <dhowells@...hat.com>,
	James Morris <jmorris@...ei.org>
Cc:	linux-kernel@...r.kernel.org
Subject: what is_single_threaded() does?

I found this helper by accident, and I am puzzled.

	/**
	 * is_single_threaded - Determine if a thread group is single-threaded or not
	 * @p: A task in the thread group in question
	 *
	 * This returns true if the thread group to which a task belongs is single
	 * threaded, false if it is not.
	 */

But this is not what the code does? The "t->mm == mm" check below means
it also returns false if ->mm is shared with another CLONE_VM process ?

Could you explain what is right, the comment or the code?

	bool is_single_threaded(struct task_struct *p)
	{
		struct task_struct *g, *t;
		struct mm_struct *mm = p->mm;

		if (atomic_read(&p->signal->count) != 1)
			goto no;

Is this correct? Let's suppose the main thread dies, and the thread group
has only one live thread. In that case signal->count == 2.


		if (atomic_read(&p->mm->mm_users) != 1) {
			read_lock(&tasklist_lock);
			do_each_thread(g, t) {

Why do_each_thread() ? for_each_process() is enough, all sub-threads use
the same ->mm.

				if (t->mm == mm && t != p)
					goto no_unlock;

What about use_mm() ? Looks like this needs PF_KTHREAD check.

			} while_each_thread(g, t);
			read_unlock(&tasklist_lock);
		}

		return true;

Perhaps it should be current_is_single_thread(void) ...

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ