(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

perf util: Fix perf_exe() buffer write past end

perf_exe() passes len to readlink() and then unconditionally writes a trailing NUL at buf[n]. If readlink() returns len, the write lands one byte past the buffer. Read at most len - 1 bytes and keep the existing NUL termination. Also guard the fallback path for tiny buffers so copying "perf" cannot overflow. Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Miguel Martín Gil <miguel.martin.gil.uni@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


Author Miguel Martín Gil Committer Arnaldo Carvalho de Melo Date Commit Parent 3dfaf02e
+11 -1
1 changed file
+11 -1
1 changed file