summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/bin
diff options
context:
space:
mode:
authorShaojie Sun <sunshaojie@kylinos.cn>2026-09-21 21:15:56 +0800
committerTejun Heo <tj@kernel.org>2026-09-21 07:20:26 -1000
commit94e32742e8199f650e9456c4a92dfe5cefb59ba5 (patch)
treee94b6df7adf3edb61da1eed8aeb70c73ba1facb8 /tools/perf/scripts/python/bin
parent47f4cdbc14247502479bdde4511022c16d91eed4 (diff)
downloadlinux-next-94e32742e8199f650e9456c4a92dfe5cefb59ba5.tar.gz
linux-next-94e32742e8199f650e9456c4a92dfe5cefb59ba5.zip
selftests/cgroup: don't crash on a truncated mount entry in cg_find_root()
cg_find_root() parses /proc/self/mounts with strtok() and assumes that every field group it walks over is a complete "device mountpoint type options freq passno" tuple. That only holds while the buffer is big enough for the whole file: if the buffer is too small, the last tuple is cut short, strtok() returns NULL for the missing fields, and the strcmp(type, ...) and strstr(options, ...) calls that follow dereference it. The current buffer is 10 * BUF_SIZE, so reaching this needs a mount table over 40K, but the crash is easy to hit in a sandbox: with BUF_SIZE overridden to 6, which leaves a 60-byte buffer, cg_find_unified_root() segfaults instead of failing. Stop parsing as soon as a field is missing. Nothing follows a truncated entry, so there is nothing to parse after it either. Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions