perf trace: Check for vfs_getname.pathname length
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 39f0e7a825cfc971dc9ad40b0770c22f6f4f89b8 Gitweb: http://git.kernel.org/tip/39f0e7a825cfc971dc9ad40b0770c22f6f4f89b8 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Fri, 24 Mar 2017 14:51:28 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 24 Mar 2017 16:05:31 -0300
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 <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/builtin-trace.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/builtin-trace.c +2 -0
@@ -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 );