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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20080129150836.7fd994a2.akpm@linux-foundation.org>
Date:	Tue, 29 Jan 2008 15:08:36 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Oleg Nesterov <oleg@...sign.ru>
Cc:	ebiederm@...ssion.com, mingo@...e.hu, paulmck@...ux.vnet.ibm.com,
	xemul@...nvz.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fix tasklist + find_pid() with CONFIG_PREEMPT_RCU

On Tue, 29 Jan 2008 19:40:19 +0300
Oleg Nesterov <oleg@...sign.ru> wrote:

> With CONFIG_PREEMPT_RCU read_lock(tasklist_lock) doesn't imply rcu_read_lock(),
> but find_pid_ns()->hlist_for_each_entry_rcu() should be safe under tasklist.
> 
> Usually it is, detach_pid() is always called under write_lock(tasklist_lock),
> but copy_process() calls free_pid() lockless.
> 
> "#ifdef CONFIG_PREEMPT_RCU" is added mostly as documentation, perhaps it is
> too ugly and should be removed.
> 
> Signed-off-by: Oleg Nesterov <oleg@...sign.ru>
> 
> --- MM/kernel/fork.c~PR_RCU	2008-01-27 17:09:47.000000000 +0300
> +++ MM/kernel/fork.c	2008-01-29 19:23:44.000000000 +0300
> @@ -1335,8 +1335,19 @@ static struct task_struct *copy_process(
>  	return p;
>  
>  bad_fork_free_pid:
> -	if (pid != &init_struct_pid)
> +	if (pid != &init_struct_pid) {
> +#ifdef CONFIG_PREEMPT_RCU
> +		/*
> +		 * read_lock(tasklist_lock) doesn't imply rcu_read_lock(),
> +		 * make sure find_pid() is safe under read_lock(tasklist).
> +		 */
> +		write_lock_irq(&tasklist_lock);
> +#endif
>  		free_pid(pid);
> +#ifdef CONFIG_PREEMPT_RCU
> +		write_unlock_irq(&tasklist_lock);
> +#endif
> +	}
>  bad_fork_cleanup_namespaces:
>  	exit_task_namespaces(p);
>  bad_fork_cleanup_keys:

My attempt to understand this change timed out.

kernel/pid.c is full of global but undocumented functions.  What are the
locking requirements for free_pid()?  free_pid_ns()?  If it's just
caller-must-hold-rcu_read_lock() then why not use rcu_read_lock() here?

If the locking is "caller must hold write_lock_irq(tasklist_lock) then the
sole relevant comment in there (in free_pid()) is wrong.

Guys, more maintainable code please?
--
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