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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 22 Mar 2010 19:18:38 -0700
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	Oleg Nesterov <oleg@...hat.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Alexey Dobriyan <adobriyan@...il.com>,
	Roland McGrath <roland@...hat.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH -mm 0/3] proc: task->signal can't be NULL

Oleg Nesterov <oleg@...hat.com> writes:

> With the recent changes in -mm it is always safe to dereference
> task->signal. It can't be NULL and it is pinned to task_struct.
>
> fs/proc becomes the only valid user of signal->count which should
> either die or become "int nr_threads".
>
>
> Alexey, Eric.
>
> Can't we kill this counter? Afaics, get_nr_threads() doesn't need to
> be "precise", we probably can estimate the number of threads using
> signal->live (yes sure, we can't use ->live as nr_threads).
>
> Except: first_tid() uses get_nr_threads() for optimization. Is this
> optimization really important? Afaics, it only helps in the unlikely
> case, probably in that case the extra lockless while_each_thread()
> doesn't hurt.
>
> IOW, how about
>
> 	--- a/fs/proc/base.c
> 	+++ b/fs/proc/base.c
> 	@@ -3071,11 +3071,6 @@ static struct task_struct *first_tid(str
> 				goto found;
> 		}
> 	 
> 	-	/* If nr exceeds the number of threads there is nothing todo */
> 	-	pos = NULL;
> 	-	if (nr && nr >= get_nr_threads(leader))
> 	-		goto out;
> 	-
> 		/* If we haven't found our starting place yet start
> 		 * with the leader and walk nr threads forward.
> 		 */
>
> ?
>
> Not that I think it is terribly important to kill this counter, and
> probably signal->nr_threads can make sense anyway, so far I am just
> curious.

I think that was just a sanity check since it was easy.  I want to say
it prevents a DOS attack with user space passing unreasonably large
file position but that DOS attack is handled by ensuring we don't walk
through the list if threads more than once.

However:
proc_task_getattr uses get_nr_threads to get it's nlink count correct.

Not walking the thread list to get the number of threads seems like an
important cpu time saving measure.

Eric

--
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