]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
src/config: Fix segfault while using templates
authorTeodor Milkov <zimage@icdsoft.com>
Thu, 12 Jun 2025 09:47:41 +0000 (15:17 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 16 Jun 2025 14:07:59 +0000 (08:07 -0600)
commitf9bd14bdc05afa2fb8077a0681dd1dfaf08f331d
tree5b0f27aed4da8a284ee1683dbd96e57ff90d90c1
parent615efc7b7dba86eb81750eb9cdc7b4c1e6594bbb
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
 #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
 #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
 #4  0x000018844cc0f29d in cgre_process_event (ev=0x79905b6ecc74, type=4) at cgrulesengd.c:485
 #5  0x000018844cc0f441 in cgre_handle_msg (cn_hdr=0x79905b6ecc60) at cgrulesengd.c:531
 #6  0x000018844cc0f678 in cgre_receive_netlink_msg (sk_nl=0) at cgrulesengd.c:596
 #7  0x000018844cc0ffe1 in cgre_create_netlink_socket_process_msg () at cgrulesengd.c:786
 #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: https://github.com/libcgroup/libcgroup/issues/483
Signed-off-by: Teodor Milkov <zimage@icdsoft.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/config.c