[CRIU] Re: [PATCH v2] restorer: move vma flags ANON bit drop alter IPC check

Pavel Emelyanov xemul at parallels.com
Fri Feb 17 07:36:28 EST 2012


On 02/17/2012 02:43 PM, Kinsbursky Stanislav wrote:
> v2: local flags variable introduced
> 
> This doesn't change anything. But looks clearer, because this check has
> nothing with SYSV IPC mappings.
> 
> Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
> 
> ---
>  restorer.c |   30 ++++++++++++++++--------------
>  1 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/restorer.c b/restorer.c
> index 3eb5e35..e0eccb4 100644
> --- a/restorer.c
> +++ b/restorer.c
> @@ -289,16 +289,29 @@ err:
>  
>  static u64 restore_mapping(const struct vma_entry *vma_entry)
>  {
> -	int prot;
> +	int prot, flags;
>  
>  	if (vma_entry_is(vma_entry, VMA_AREA_SYSVIPC))
>  		return sys_shmat(vma_entry->fd, (void *)vma_entry->start,
>  				 (vma_entry->prot & PROT_WRITE) ? 0 : SHM_RDONLY);
>  
> +	flags = vma_entry->flags;
> +
> +	/*
> +	 * Restore or shared mappings are tricky, since
> +	 * we open anonymous mapping via map_files/
> +	 * MAP_ANONYMOUS should be eliminated so fd would
> +	 * be taken into account by a kernel.
> +	 */
> +	if (vma_entry_is(vma_entry, VMA_ANON_SHARED)) {
> +		if (vma_entry->fd != -1UL)

Write both conditions in on if ().

> +			flags &= ~MAP_ANONYMOUS;
> +	}
> +
>  	prot = vma_entry->prot;
>  
>  	/* A mapping of file with MAP_SHARED is up to date */
> -	if (vma_entry->fd == -1 || !(vma_entry->flags & MAP_SHARED))
> +	if (vma_entry->fd == -1 || !(flags & MAP_SHARED))
>  		prot |= PROT_WRITE;
>  
>  	/*
> @@ -309,7 +322,7 @@ static u64 restore_mapping(const struct vma_entry *vma_entry)
>  	return sys_mmap((void *)vma_entry->start,
>  			vma_entry_len(vma_entry),
>  			prot,
> -			vma_entry->flags | MAP_FIXED,
> +			flags | MAP_FIXED,
>  			vma_entry->fd,
>  			vma_entry->pgoff);
>  }
> @@ -401,17 +414,6 @@ long restore_task(struct task_restore_core_args *args)
>  		if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
>  			continue;
>  
> -		/*
> -		 * Restore or shared mappings are tricky, since
> -		 * we open anonymous mapping via map_files/
> -		 * MAP_ANONYMOUS should be eliminated so fd would
> -		 * be taken into account by a kernel.
> -		 */
> -		if (vma_entry_is(vma_entry, VMA_ANON_SHARED)) {
> -			if (vma_entry->fd != -1UL)
> -				vma_entry->flags &= ~MAP_ANONYMOUS;
> -		}
> -
>  		va = restore_mapping(vma_entry);
>  
>  		if (va != vma_entry->start) {
> 



More information about the CRIU mailing list