]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tools/cgclassify: fix controller overflow array range
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 3 Jul 2023 05:05:40 +0000 (10:35 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 3 Jul 2023 15:04:57 +0000 (09:04 -0600)
commitedc33e06e0232974ded1339dd3cfcdd004e83281
tree845458b042ddac69f09f499b381efe1987e4d1b7
parent896a365c928066d95ec16e80fe70466e961b12d4
tools/cgclassify: fix controller overflow array range

Fix out-of-bounds write issue, reported by Coverity tool:

CID 321270 (#1 of 1): Out-of-bounds write (OVERRUN)47. overrun-local:
Overrunning array info of 16 4128-byte elements at element index 16
(byte offset 70175) using index i (which evaluates to 16).

MAX_MNT_ELEMENTS is an array that's allocated for array parsing and
populating the mount points, as per Linux Kernel, this can't be above
16 and it works fine while checking for index < MAX_MNT_ELEMENTS, but
in this case, we rely on the mount point name to be empty ('\0'), since
allowed maximum mount points are 16, increase the allocation index to
17 for the info structure, to accommodate 16 controllers, but that is
unlikely.

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