[CRIU] [PATCH] restore: Serialize access to last_pid

Andrey Vagin avagin at gmail.com
Sun Nov 17 12:13:58 MSK 2019


On Fri, Nov 15, 2019 at 05:33:34PM +0300, Cyrill Gorcunov wrote:
> @@ -23,9 +80,13 @@ int clone_noasan(int (*fn)(void *), int flags, void *arg)
>  {
>  	void *stack_ptr = (void *)round_down((unsigned long)&stack_ptr - 1024, 16);
>  	BUG_ON((flags & CLONE_VM) && !(flags & CLONE_VFORK));
> +	int ret;
>  	/*
>  	 * Reserve some bytes for clone() internal needs
>  	 * and use as stack the address above this area.
>  	 */
> -	return clone(fn, stack_ptr, flags, arg);
> +	context_lock();
> +	ret = clone(fn, stack_ptr, flags, arg);

Here is one more problem. clone can fork a process with a pid which is
going to be used be one of restored threads.

> +	context_unlock();
> +	return ret;
>  }


More information about the CRIU mailing list