]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api.c: fix segfault in cgroup_populate_mount_points()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 2 May 2022 21:40:36 +0000 (15:40 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 2 May 2022 21:40:41 +0000 (15:40 -0600)
commit9ce90c7edd281b359f67ee15b67fd28083ed4167
tree0c1039472ec9fcdf61b9ffd9b9cd52e70aa6a2a9
parent5ed84ad3eb8f9af1a070c60defbce3fb3f16d247
api.c: fix segfault in cgroup_populate_mount_points()

In cgroup_populate_mount_points(),  cgroup v1/v2 mount points get read
from /proc/mounts and populated into cg_mount_table[].  The size of
cg_mount_table[] is set to CG_CONTROLLER_MAX, that's defined as 100 and
if the system has more than CG_CONTROLLER_MAX, unique mount points, it
will segfault while processing them.  Fix this by checking, the mount
point count after processing every mount entry and bailout in case it
reaches CG_CONTROLLER_MAX.

The issue can be reproduced using, following simple bash commands on
cgroup v1:
1. sudo for i in $(seq 0 100); do sudo mkdir /name$i; done
2. sudo for i in $(seq 0 86); do sudo mount -t cgroup -o none,name=named$i
none /name$i; done
3. sudo cgget -g <controller>:<existing cgroup name>

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c