Commit ab7dd30
committed
config: pass NULL when probing systemd default cgroup
ASan reported following global-buffer-overflow:
READ of size 1 at 0x7f50dc6b3e9f thread T0
#0 0x... in cg_concat_path <src>/src/api.c:1769
#1 0x... in cg_build_path_locked <src>/src/api.c:1889
libcgroup#2 0x... in cg_build_path <src>/src/api.c:1910
libcgroup#3 0x.. in systemd_default_cgroup_exists <src>/src/config.c:2258
libcgroup#4 0x.. in cgroup_set_default_systemd_cgroup <src>/src/config.c:2306
libcgroup#5 0x... in main <src>/src/tools/cgdelete.c:193
libcgroup#6 0x... in __libc_start_call_main (/lib64/libc.so.6+0x2a60f)
libcgroup#7 0x... in __libc_start_main_alias_2 (/lib64/libc.so.6+0x2a6bf)
libcgroup#8 0x... in _start (/usr/local/bin/cgdelete+0x402384)
0x... sits one byte to the left of the empty string literal '.LC3' that
systemd_default_cgroup_exists() handed to cg_build_path(). Passing an
empty suffix made cg_concat_path() evaluate suf[-1] while it decided
whether to append a trailing slash, triggering the ASan
global-buffer-overflow.
Fix by passing NULL, instead of "" (empty string) so cg_build_path()
skips the suffix concatenation entirely. The resulting canonical paths
are unchanged, but cgdelete (and any other caller) now runs without
trampling the adjacent literal.
Fixes: libcgroup#526
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>1 parent 2c6bcc4 commit ab7dd30
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2264 | 2264 | | |
2265 | 2265 | | |
2266 | 2266 | | |
2267 | | - | |
| 2267 | + | |
2268 | 2268 | | |
2269 | 2269 | | |
2270 | 2270 | | |
2271 | 2271 | | |
2272 | | - | |
| 2272 | + | |
2273 | 2273 | | |
2274 | 2274 | | |
2275 | 2275 | | |
| |||
0 commit comments