#41 cgroup_free_controllers() gives segmentation fault

open-accepted
None
5
2008-11-29
2008-11-18
No

Hi
Calling cgroup_free_controllers() with null cgroup gives segmentation fault.
A simple call to
cgroup_free_controllers(cgroup2);
gives this segfault. cgroup2 is null.

The following patch fixes this issue.

Index: trunk/wrapper.c

--- trunk.orig/wrapper.c
+++ trunk/wrapper.c
@@ -76,6 +76,10 @@ struct cgroup_controller *cgroup_add_con
void cgroup_free_controllers(struct cgroup *cgroup)
{
int i, j;
+
+ if (!cgroup)
+ return;
+
for (i = 0; i < cgroup->index; i++) {
for (j = 0; j < cgroup->controller[i]->index; j++)
free(cgroup->controller[i]->values[j]);
~

Discussion

  • Dhaval Giani

    Dhaval Giani - 2008-11-22

    Though I have merged the patch in, i don;t believe its the right solution. cgroup_free checks if the cgroup is null before passing it on. a null cgroup should never have made it there. This needs deeper checking. Sudhir, can I ask you to provide the gdb trace for this.

     
  • Dhaval Giani

    Dhaval Giani - 2008-11-22
    • assigned_to: nobody --> dhaval_giani
     
  • Sudhir Kumar

    Sudhir Kumar - 2008-11-22

    But one can not guarantee that an independent call will not be made to cgroup_freee_controllers(). If it is through cgroup_free(), well and good, but if independently then it will cause a fault. So it looks a fair enough solution to me.

     
  • Dhaval Giani

    Dhaval Giani - 2008-11-22

    yikes! That is very wrong. Coming up a patch which moves out the cgroup_free_controller from libcgroup.h and makes it static. It should never ever be called from outside.

     
  • Sudhir Kumar

    Sudhir Kumar - 2008-11-29
    • status: open --> closed
     
  • Dhaval Giani

    Dhaval Giani - 2008-11-29
    • status: closed --> open-accepted
     
  • Dhaval Giani

    Dhaval Giani - 2008-11-29

    Reopening this, since this is still needs to be fixed with a better solution.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks