[Devel] [PATCH criu v7-u5 1/2] mount: restore_task_mnt_ns - Lookup for mount namespace conditionally

Andrey Vagin avagin at virtuozzo.com
Tue Jul 25 20:26:17 MSK 2017


On Sat, Jul 22, 2017 at 01:27:08PM +0300, Cyrill Gorcunov wrote:
> In case if our parent is a dead task (zombie) we should lookup
> for parent ids which will be inherited on restore. Otherwise
> parent->ids may be nil and SIGSEGV produced.
> 
> https://jira.sw.ru/browse/PSBM-68062
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
> ---
>  criu/mount.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/mount.c b/criu/mount.c
> index 2ec94b3..1066663 100644
> --- a/criu/mount.c
> +++ b/criu/mount.c
> @@ -3069,6 +3069,7 @@ int restore_task_mnt_ns(struct pstree_item *current)
>  		return 0;
>  
>  	if (current->ids && current->ids->has_mnt_ns_id) {
> +		struct pstree_item *next = current->parent;
>  		unsigned int id = current->ids->mnt_ns_id;
>  		struct ns_id *nsid;
>  
> @@ -3081,8 +3082,10 @@ int restore_task_mnt_ns(struct pstree_item *current)
>  		 * already there, otherwise it will have to do
>  		 * setns().
>  		 */
> -		if (current->parent && id == current->parent->ids->mnt_ns_id)
> -			return 0;
> +		for (; next; next = next->parent) {
> +			if (next->ids && id == next->ids->mnt_ns_id)
> +				return 0;

^^^ It is incorrect. We want to check that a parent task lives in this
same mount namespace.

The code has to be something like this:

			if (next->ids == NULL) /* helper or zombie */
				break;

			if (id == next->ids->mnt_ns_id)
				return 0;

Or it may be better to set ids for such tasks.

> +		}
>  
>  		nsid = lookup_ns_by_id(id, &mnt_ns_desc);
>  		if (nsid == NULL) {
> -- 
> 2.7.5
> 


More information about the Devel mailing list