[CRIU] [PATCH 1/9] restore_root_task(): don't fiddle with closed fd

Andrew Vagin avagin at odin.com
Wed Oct 7 04:22:12 PDT 2015


On Wed, Oct 07, 2015 at 02:44:16AM -0700, Kir Kolyshkin wrote:
> In restore_root_task() function, mnt_ns_fd is closed, but then
> the function calls try_clean_remaps(mnt_ns_fd) which tries to do
> something with the file descriptor which is already closed.
> 
> Fix by setting it to -1 after closing.

https://lists.openvz.org/pipermail/criu/2015-October/022431.html

> 
> Reported by Coverity, CID 114629.
> 
> Signed-off-by: Kir Kolyshkin <kir at openvz.org>
> ---
>  cr-restore.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index 33205e4..90313a4 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1847,12 +1847,14 @@ static int restore_root_task(struct pstree_item *init)
>  	 */
>  	task_entries->nr_threads -= atomic_read(&task_entries->nr_zombies);
>  
> -	if (mnt_ns_fd >= 0)
> +	if (mnt_ns_fd >= 0) {
>  		/*
>  		 * Don't try_clean_remaps here, since restore went OK
>  		 * and all ghosts were removed by the openers.
>  		 */
>  		close(mnt_ns_fd);
> +		mnt_ns_fd = -1;
> +	}
>  	cleanup_mnt_ns();
>  
>  	ret = stop_usernsd();
> -- 
> 2.4.3
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list