[CRIU] Re: [PATCH] restorer: don't close SYSV IPC vma fd

Stanislav Kinsbursky skinsbursky at parallels.com
Fri Feb 17 06:04:01 EST 2012


To many mistakes in patch comment.
Here is a correct one:
"
It's not a fd to open and map, but SYSV IPC id instead. So don't close it - this 
can lead to unpredictable results (in case of SYSV IPC id will match fd, opened 
by processes).
"


17.02.2012 14:56, Kinsbursky Stanislav пишет:
> If't not a fd, used for open and but, but SYSV IPC id instead.
> So don't close it - this can lead to unpredictable resultd (if SYSV IPC id
> will match with real fd, opened by processes.
>
> Signed-off-by: Stanislav Kinsbursky<skinsbursky at openvz.org>
>
> ---
>   restorer.c |   12 +++++++-----
>   1 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/restorer.c b/restorer.c
> index e0eccb4..c333b95 100644
> --- a/restorer.c
> +++ b/restorer.c
> @@ -290,6 +290,7 @@ err:
>   static u64 restore_mapping(const struct vma_entry *vma_entry)
>   {
>   	int prot, flags;
> +	u64 addr;
>
>   	if (vma_entry_is(vma_entry, VMA_AREA_SYSVIPC))
>   		return sys_shmat(vma_entry->fd, (void *)vma_entry->start,
> @@ -319,12 +320,17 @@ static u64 restore_mapping(const struct vma_entry *vma_entry)
>   	 * writable since we're going to restore page
>   	 * contents.
>   	 */
> -	return sys_mmap((void *)vma_entry->start,
> +	addr = sys_mmap((void *)vma_entry->start,
>   			vma_entry_len(vma_entry),
>   			prot,
>   			flags | MAP_FIXED,
>   			vma_entry->fd,
>   			vma_entry->pgoff);
> +
> +	if (vma_entry->fd != -1UL)
> +		sys_close(vma_entry->fd);
> +
> +	return addr;
>   }
>
>   /*
> @@ -427,10 +433,6 @@ long restore_task(struct task_restore_core_args *args)
>   			write_hex_n(va);
>   			goto core_restore_end;
>   		}
> -
> -		if (vma_entry->fd != -1UL)
> -			sys_close(vma_entry->fd);
> -
>   	}
>
>   	/*
>


-- 
Best regards,
Stanislav Kinsbursky



More information about the CRIU mailing list