On Thu, 19 May 2022 06:00:06 GMT, Ioi Lam <ik...@openjdk.org> wrote: >> Severin Gehwolf has updated the pull request incrementally with two >> additional commits since the last revision: >> >> - Refactor hotspot gtest >> - Separate into function. Fix comment. > > src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp line 86: > >> 84: const char* cgroup_p = cgroup_path; >> 85: int last_slash = find_last_slash_pos(root_p, cgroup_p); >> 86: assert(last_slash >= 0, "not an absolute path?"); > > Are root_p and cgroup_p directly read from the /proc/xxx files. If so, do we > validate the input to make sure they are absolute paths? > > It seems like our code cannot handle trailing '/' in the input. If so, we > should clear all trailing '/' from the input string. Then, in functions that > process them, we should assert that they don't end with slash. See my comment > in find_last_slash_pos().
Yes, those values come from `/proc/self/mountinfo` and `/proc/self/cgroup`. There is no validation being done. Then again, we only end up in this branch if the root path is not a substring of the cgroup path. In that case trailing slashes don't matter, since there would not be a character by character match earlier. I'll add handling of trailing slashes and appropriate asserts where it makes sense. ------------- PR: https://git.openjdk.java.net/jdk/pull/8629