[CRIU] [PATCH] net: don't call netns_entry__free_unpacked for uninitialized pointer

Tycho Andersen tycho.andersen at canonical.com
Tue Jun 9 04:42:00 PDT 2015


On Tue, Jun 09, 2015 at 02:24:48PM +0300, Andrey Vagin wrote:
> If the netns image is absent, the NetnsEntry entry will not be initialized.
> 
> Currently restore from old images crashes:
> 
> Core was generated by `criu swrk 3'.
> Program terminated with signal SIGSEGV, Segmentation fault.
> $0  0x0000000000427d80 in netns_entry.free_unpacked ()
> (gdb) bt
> $0  0x0000000000427d80 in netns_entry.free_unpacked ()
> $1  0x0000000000436d07 in prepare_net_ns ()
> $2  0x0000000000457c78 in prepare_namespace ()
> $3  0x0000000000432917 in restore_task_with_children ()
> $4  0x00007fc86acfccfd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
> 
> Cc: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  cr-service.c | 1 +
>  crtools.c    | 2 +-
>  net.c        | 5 +++--
>  3 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/cr-service.c b/cr-service.c
> index 60a7289..98601f8 100644
> --- a/cr-service.c
> +++ b/cr-service.c
> @@ -269,6 +269,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
>  		opts.output = req->log_file;
>  	} else
>  		opts.output = DEFAULT_LOG_FILENAME;
> +	opts.output = "/tmp/restore.log";
>  
>  	log_set_loglevel(req->log_level);
>  	if (log_init(opts.output) == -1) {
> diff --git a/crtools.c b/crtools.c
> index f83db27..61e03c9 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -288,7 +288,7 @@ int main(int argc, char *argv[], char *envp[])
>  			work_dir = optarg;
>  			break;
>  		case 'o':
> -			opts.output = optarg;
> +			opts.output = "/tmp/restore.log";//optarg;

I guess this and the hunk above are debugging?

Tycho

>  			break;
>  		case 'n':
>  			if (parse_ns_string(optarg))
> diff --git a/net.c b/net.c
> index e7354a4..082ccb6 100644
> --- a/net.c
> +++ b/net.c
> @@ -728,12 +728,13 @@ int dump_net_ns(int ns_id)
>  int prepare_net_ns(int pid)
>  {
>  	int ret;
> -	NetnsEntry *netns;
> +	NetnsEntry *netns = NULL;
>  
>  	ret = restore_netns_conf(pid, &netns);
>  	if (!ret)
>  		ret = restore_links(pid, &netns);
> -	netns_entry__free_unpacked(netns, NULL);
> +	if (netns)
> +		netns_entry__free_unpacked(netns, NULL);
>  
>  	if (!ret)
>  		ret = restore_ifaddr(pid);
> -- 
> 2.1.0
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list