From 480176e2f27ae2e0b0b9c7e0afa8872e82c60a61 Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Fri, 14 Apr 2023 15:30:01 +0000 Subject: [PATCH] tools/cgxget: fix segfault in free path cgxget tool crashes, when passing basic operations such as multiple cgroups as arguments or invalid parameters, it turns out the address of struct cgroup passed for cgroup_free() has been invalid. $ sudo ./src/tools/cgxget -1 -r cpu.shares a b Segmentation fault (core dumped) $ sudo ./src/tools/cgxget -1 cpu.shares a b Segmentation fault (core dumped) this patch fixes it by passing the right address of the struct cgroup[] to cgroup_free(). Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka (cherry picked from commit a1299d6cd01fbff653a3fe919a67ea86483a054e) --- src/tools/cgxget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cgxget.c b/src/tools/cgxget.c index 225e3a63..a9eb0fd2 100644 --- a/src/tools/cgxget.c +++ b/src/tools/cgxget.c @@ -823,7 +823,7 @@ out: * Free the old list. */ for (i = 0; i < cg_list_len; i++) - cgroup_free(cg_list[i]); + cgroup_free(&(*cg_list)[i]); *cg_list = cg_converted_list; } -- 2.47.2