• Oleg Nesterov's avatar
    [PATCH] simplify/fix first_tid() · a872ff0c
    Oleg Nesterov authored
    first_tid:
    
    	/* If nr exceeds the number of threads there is nothing todo */
    	if (nr) {
    		if (nr >= get_nr_threads(leader))
    			goto done;
    	}
    
    This is not reliable: sub-threads can exit after this check, so the
    'for' loop below can overlap and proc_task_readdir() can return an
    already filldir'ed dirents.
    
    	for (; pos && pid_alive(pos); pos = next_thread(pos)) {
    		if (--nr > 0)
    			continue;
    
    Off-by-one error, will return 'leader' when nr == 1.
    
    This patch tries to fix these problems and simplify the code.
    Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
    Cc: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    a872ff0c
base.c 55.5 KB