Re: [libvirt] [PATCH] Avoid libvirtd crash when cgroups is not configured on host

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 21, 2010 at 08:07:15PM -0600, Jim Fehlig wrote:
> Patch for libvirtd segfault discussed on IRC recently ...
> 
> Regards,
> Jim
> 
> 

> commit f034c0bfd7089ba3400b7a44b97540c4a8785e35
> Author: Jim Fehlig <jfehlig@xxxxxxxxxx>
> Date:   Sun Mar 21 19:59:13 2010 -0600
> 
>     Avoid libvirtd crash when cgroups is not configured on host
>     
>     Invoking virDomainSetMemory() on lxc driver results in libvirtd
>     segfault when cgroups has not been configured on the host.
>     
>     Ensure driver->cgroup is non-null before invoking
>     virCgroupForDomain().  To prevent similar segfaults in the future,
>     ensure driver parameter to virCgroupForDomain() is non-null before
>     dereferencing.
> 
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index aeec593..ba13065 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -625,6 +625,12 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
>      }
>  
>      if (virDomainObjIsActive(vm)) {
> +        if (driver->cgroup == NULL) {
> +            lxcError(VIR_ERR_NO_SUPPORT,
> +                     "%s", _("cgroups must be configured on the host"));
> +            goto cleanup;
> +        }
> +
>          if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) {
>              lxcError(VIR_ERR_INTERNAL_ERROR,
>                       _("Unable to get cgroup for %s\n"), vm->def->name);
> diff --git a/src/util/cgroup.c b/src/util/cgroup.c
> index 8777781..496d9d3 100644
> --- a/src/util/cgroup.c
> +++ b/src/util/cgroup.c
> @@ -692,6 +692,9 @@ int virCgroupForDomain(virCgroupPtr driver,
>      int rc;
>      char *path;
>  
> +    if (driver == NULL)
> +        return -EINVAL;
> +
>      if (virAsprintf(&path, "%s/%s", driver->path, name) < 0)
>          return -ENOMEM;

ACK


Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]