From: Arnaldo Carvalho de Melo Date: Fri, 24 Mar 2017 17:51:28 +0000 (-0300) Subject: perf trace: Check for vfs_getname.pathname length X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=39f0e7a825cfc971dc9ad40b0770c22f6f4f89b8;p=openwrt%2Fstaging%2Fblogic.git perf trace: Check for vfs_getname.pathname length It shouldn't be zero, but if the 'perf probe' on getname_flags() (or elsewhere in the future we need to probe to catch the pathname for syscalls like 'open' being copied from userspace to the kernel) is misplaced somehow, then we will end up not allocating space and trying to copy the "" empty string to ttrace->filename.name, causing a segfault, fix it. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-c4f1t6sx1nczuzop19r5si5s@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 912fedc5b42d..33c657c15d5e 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1656,6 +1656,8 @@ static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel, goto out; filename_len = strlen(filename); + if (filename_len == 0) + goto out; if (ttrace->filename.namelen < filename_len) { char *f = realloc(ttrace->filename.name, filename_len + 1);