[lxc-devel] Segfault in lxc-create of lxc 4.0.5

Robert Vogelgesang vogel at folz.de
Fri Oct 23 13:31:20 UTC 2020


Hello @all,

currently, I'm testing lxc 4.0.5 with multiple Linux distro's,
and on some of them lxc-create(1) segfaulted.

When I run lxc-create(1) in GDB, I get:

Program received signal SIGSEGV, Segmentation fault.
x0i0007ffff7b6be79 in do_lxcapi_create (c=c at entry=0x6980b0, t=t at entry=0x7fffffffe874 "vserver", bdevtype=bdevtype at entry=0x0, specs=specs at entry=0x7fffffffe4b0, flags=flags at entry=0, argv=argv at entry=0x7fffffffe640) at lxccontainer.c:1923
1923                    bool reset_managed = c->lxc_conf->rootfs.managed;

This is near the end of do_lxcapi_create().  A few lines before,
the config is reset:

        /* Reload config to get the rootfs. */
        lxc_conf_free(c->lxc_conf);
        c->lxc_conf = NULL;

The segfault happens when recreating the configuration fails afterwards,
e. g. when prepend_lxc_header() returns failure.

The reason for prepend_lxc_header() failing was a missing call to
	OpenSSL_add_all_digests();
just before
	md = EVP_get_digestbyname("sha1");
in src/lxc/utils.c; openssl versions older than 1.1.0 need this.

My question now is: What's the correct fix for the segfault?
container_destroy() needs a valid configation in c->lxc_conf.
Maybe we have to preserve the old c->lxc_conf until the new 
configuration was created?

Best regards,

Robert



More information about the lxc-devel mailing list