Bug 1057676 - Cgroup templates not getting applied because of bad struct copy
Summary: Cgroup templates not getting applied because of bad struct copy
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libcgroup
Version: 6.6
Hardware: All
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: Jan Chaloupka
QA Contact: Red Hat Kernel QE team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-24 15:26 UTC by Josko Plazonic
Modified: 2014-10-14 06:44 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-14 06:44:59 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1480 normal SHIPPED_LIVE libcgroup bug fix and enhancement update 2014-10-14 01:10:34 UTC

Description Josko Plazonic 2014-01-24 15:26:25 UTC
Description of problem:
With the latest libcgroup-0.40.rc1-5.el6_5.1 in our testing we had template limits (like template users/%u in cgconfig.conf) not getting applied to users.  We tracked it down to:
cgroup_copy_cgroup(&config_template_table[i], &template_table[i]);
line 1533 of src/config.c - which has the wrong order (should be DEST,SRC) so the just parsed config_template_table is getting overwritten with an empty one.  Also template name and other params are not getting copied. Indeed 0.41 version of libcgroup has that fixed.

Version-Release number of selected component (if applicable):
libcgroup-0.40.rc1-5.el6_5.1

How reproducible:
every time

Steps to Reproduce:
1. add to /etc/cgconfig.conf template like:
group everyone {
        cpu {
                cpu.shares = 100;
        }
        memory {
                memory.limit_in_bytes = 61G;
                memory.memsw.limit_in_bytes = 65G;
                memory.use_hierarchy = 1;
        }
}
template everyone/%u {
        cpu {
                cpu.shares = 10;
        }
        memory {
                memory.limit_in_bytes = 30G;
                memory.memsw.limit_in_bytes = 32G;
        }
}
2. and add to /etc/cgrules.conf:
*               cpu,memory      everyone/%u
3. Start cgconfig and cgred services, login as a user

Actual results:
Check /cgroups/everyone/username/memory.limits_in_bytes and notice that there are no limits imposed.

Expected results:
Expecting limits as specified.

Additional info:
This is fixed in libcgroup-0.41 - this is the relevant excerpt from diff on src/config.c:
@@ -1483,7 +1483,24 @@
        }
 
        for (i = 0; i < template_table_index; i++) {
-               cgroup_copy_cgroup(&config_template_table[i], &template_table[i]);
+               cgroup_copy_cgroup(&template_table[i],
+                       &config_template_table[i]);
+               strcpy((template_table[i]).name,
+                       (config_template_table[i]).name);
+               template_table[i].tasks_uid =
+                       config_template_table[i].tasks_uid;
+               template_table[i].tasks_gid =
+                       config_template_table[i].tasks_gid;
+               template_table[i].task_fperm =
+                       config_template_table[i].task_fperm;
+               template_table[i].control_uid =
+                       config_template_table[i].control_uid;
+               template_table[i].control_gid =
+                       config_template_table[i].control_gid;
+               template_table[i].control_fperm =
+                       config_template_table[i].control_fperm;
+               template_table[i].control_dperm =
+                       config_template_table[i].control_dperm;
        }
 
        return ret;
@@ -1530,7 +1547,24 @@
        }
 
        for (i = 0; i < template_table_index; i++) {
-               cgroup_copy_cgroup(&config_template_table[i], &template_table[i]);
+               cgroup_copy_cgroup(&template_table[i],
+                       &config_template_table[i]);
+               strcpy((template_table[i]).name,
+                       (config_template_table[i]).name);
+               template_table[i].tasks_uid =
+                       config_template_table[i].tasks_uid;
+               template_table[i].tasks_gid =
+                       config_template_table[i].tasks_gid;
+               template_table[i].task_fperm =
+                       config_template_table[i].task_fperm;
+               template_table[i].control_uid =
+                       config_template_table[i].control_uid;
+               template_table[i].control_gid =
+                       config_template_table[i].control_gid;
+               template_table[i].control_fperm =
+                       config_template_table[i].control_fperm;
+               template_table[i].control_dperm =
+                       config_template_table[i].control_dperm;
        }
 
        return ret;

Comment 5 errata-xmlrpc 2014-10-14 06:44:59 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1480.html


Note You need to log in before you can comment on or make changes to this bug.