Skip to content

Commit 57e4493

Browse files
Teodor Milkovkamalesh-babulal
authored andcommitted
src/config: Fix segfault while using templates
An intermittent segmentation fault occurs when classifying tasks using cgrulesengd in combination with a template defined in cgconfig.conf. Backtrace: (gdb) bt #0 __strcmp_evex () at ../sysdeps/x86_64/multiarch/strcmp-evex.S:295 #1 0x00007079d2e69645 in cgroup_config_create_template_group (cgroup=0x18844f834600, template_name=0x18844f710cd0 "system/hosting-users/%g/mail-delivery", flags=1) at config.c:1950 libcgroup#2 0x00007079d2e61458 in cgroup_create_template_group (orig_group_name=0x79905b6ebb70 "system/hosting-users/ryleeisitt/mail-delivery", tmp=0x18844f69cce0, flags=1) at api.c:4609 libcgroup#3 0x00007079d2e61bcd in cgroup_change_cgroup_flags (uid=0, gid=674, procname=0x18844f79c310 "/var/qmail/bin/qmail-queue-wrapper", pid=1048, flags=1) at api.c:4811 libcgroup#4 0x000018844cc0f29d in cgre_process_event (ev=0x79905b6ecc74, type=4) at cgrulesengd.c:485 libcgroup#5 0x000018844cc0f441 in cgre_handle_msg (cn_hdr=0x79905b6ecc60) at cgrulesengd.c:531 libcgroup#6 0x000018844cc0f678 in cgre_receive_netlink_msg (sk_nl=0) at cgrulesengd.c:596 libcgroup#7 0x000018844cc0ffe1 in cgre_create_netlink_socket_process_msg () at cgrulesengd.c:786 libcgroup#8 0x000018844cc10e4e in main (argc=3, argv=0x79905b6eda58) at cgrulesengd.c:1282 Fix the issue using cgroup->index that holds the count of controllers, populated for the cgroup instead of checking for cgroup->controller[index] is NULL. Fixes: libcgroup#483 Signed-off-by: Teodor Milkov <zimage@icdsoft.com> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
1 parent 86a3718 commit 57e4493

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ int cgroup_config_create_template_group(struct cgroup *cgroup, char *template_na
19461946
}
19471947

19481948
/* template name match */
1949-
for (k = 0; t_cgroup->controller[k] != NULL; k++) {
1949+
for (k = 0; k < t_cgroup->index; k++) {
19501950
if (strcmp((cgroup->controller[i])->name,
19511951
(t_cgroup->controller[k])->name) != 0) {
19521952
/* controller name does not match */

0 commit comments

Comments
 (0)