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] [day] [month] [year] [list]
Date:	Fri, 5 Oct 2012 16:47:29 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Andrew Vagin <avagin@...nvz.org>
Cc:	linux-kernel@...r.kernel.org, criu@...nvz.org,
	Pavel Emelyanov <xemul@...allels.com>,
	Cyrill Gorcunov <gorcunov@...nvz.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	"Eric W. Biederman" <ebiederm@...ssion.com>
Subject: Re: [PATCH] pidns: remove recursion from free_pid_ns

On 10/05, Andrew Vagin wrote:
>
> Here is a stack trace of recursion:
> free_pid_ns(parent)
>   put_pid_ns(parent)
>     kref_put(&ns->kref, free_pid_ns);
>       free_pid_ns
>
> This patch turns recursion into loops.

I think the patch is correct, a couple of minor nits.

> +static inline int __kref_put(struct kref *kref)
> +{
> +	return atomic_sub_and_test(1, &kref->refcount);

perhaps atomic_dec_and_test(&kref->refcount) makes more sense?

> +}
> @@ -138,11 +138,20 @@ void free_pid_ns(struct kref *kref)
>
>  	ns = container_of(kref, struct pid_namespace, kref);
>
> -	parent = ns->parent;
> -	destroy_pid_namespace(ns);
> +	while (1) {
>
> -	if (parent != NULL)
> -		put_pid_ns(parent);
> +		parent = ns->parent;
> +		destroy_pid_namespace(ns);
> +
> +		if (parent == NULL || parent == &init_pid_ns)
                    ^^^^^^^^^^^^^^

Why ns->parent == NULL is only possible if ns == init_pid_ns, right?
But in this case we should not be here. The caller verifies that
initial ns != init_pid_ns, and this loops should stop once we reach
init_pid_ns.

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