linux-stable/tools/perf
Numfor Mbiziwo-Tiapo 0a19fff567 perf header: Fix use of unitialized value warning
[ Upstream commit 20f9781f49 ]

When building our local version of perf with MSAN (Memory Sanitizer) and
running the perf record command, MSAN throws a use of uninitialized
value warning in "tools/perf/util/util.c:333:6".

This warning stems from the "buf" variable being passed into "write".
It originated as the variable "ev" with the type union perf_event*
defined in the "perf_event__synthesize_attr" function in
"tools/perf/util/header.c".

In the "perf_event__synthesize_attr" function they allocate space with a malloc
call using ev, then go on to only assign some of the member variables before
passing "ev" on as a parameter to the "process" function therefore "ev"
contains uninitialized memory. Changing the malloc call to zalloc to initialize
all the members of "ev" which gets rid of the warning.

To reproduce this warning, build perf by running:
make -C tools/perf CLANG=1 CC=clang EXTRA_CFLAGS="-fsanitize=memory\
 -fsanitize-memory-track-origins"

(Additionally, llvm might have to be installed and clang might have to
be specified as the compiler - export CC=/usr/bin/clang)

then running:
tools/perf/perf record -o - ls / | tools/perf/perf --no-pager annotate\
 -i - --stdio

Please see the cover letter for why false positive warnings may be
generated.

Signed-off-by: Numfor Mbiziwo-Tiapo <nums@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Drayton <mbd@fb.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190724234500.253358-2-nums@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-08-25 10:47:53 +02:00
..
arch perf record: Fix module size on s390 2019-08-16 10:12:41 +02:00
bench perf bench numa: Add define for RUSAGE_THREAD if not present 2019-05-25 18:23:46 +02:00
Documentation perf config: Fix an error in the config template documentation 2019-04-20 09:15:57 +02:00
examples/bpf perf trace: Handle "bpf-output" events associated with "__augmented_syscalls__" BPF map 2018-08-08 15:55:57 -03:00
include/bpf perf bpf: Add wrappers to BPF_FUNC_probe_read(_str) functions 2018-08-08 15:55:57 -03:00
jvmti perf jvmti: Address gcc string overflow warning for strncpy() 2019-07-26 09:14:04 +02:00
pmu-events perf vendor events intel: Fix Load_Miss_Real_Latency on SKL/SKX 2019-01-26 09:32:40 +01:00
python perf python: Make twatch.py work with both python2 and python3 2018-02-19 12:28:08 -03:00
scripts perf script python: Fix export-to-sqlite.py sample columns 2018-09-25 11:37:05 -03:00
tests perf test mmap-thread-lookup: Initialize variable to suppress memory sanitizer warning 2019-07-31 07:27:06 +02:00
trace perf trace beauty: Add beautifiers for 'socket''s 'protocol' arg 2018-07-31 10:52:47 -03:00
ui perf hists browser: Fix potential NULL pointer dereference found by the smatch tool 2019-07-31 07:27:06 +02:00
util perf header: Fix use of unitialized value warning 2019-08-25 10:47:53 +02:00
.gitignore
Build
builtin-annotate.c perf annotate: Add --percent-type option 2018-08-08 15:55:53 -03:00
builtin-bench.c
builtin-buildid-cache.c perf buildid-cache: Warn --purge-all failures 2018-05-15 10:32:16 -03:00
builtin-buildid-list.c
builtin-c2c.c perf c2c: Fix c2c report for empty numa node 2019-04-05 22:32:57 +02:00
builtin-config.c
builtin-data.c
builtin-diff.c perf hists: Clarify callchain disabling when available 2018-07-24 14:37:33 -03:00
builtin-evlist.c
builtin-ftrace.c perf ftrace: Append an EOL when write tracing files 2018-02-19 09:49:12 -03:00
builtin-help.c perf help: Remove needless use of strncpy() 2019-07-03 13:14:41 +02:00
builtin-inject.c perf thread: Make thread__find_map() return the map 2018-04-26 13:47:08 -03:00
builtin-kallsyms.c perf machine: Ditch find_kernel_function variants 2018-04-30 12:20:54 -03:00
builtin-kmem.c tools lib traceevent, perf tools: Rename 'enum pevent_flag' to 'enum tep_flag' 2018-08-13 15:22:18 -03:00
builtin-kvm.c perf tools: Ditch the symbol_conf.nr_events global 2018-06-04 10:28:52 -03:00
builtin-list.c
builtin-lock.c
builtin-mem.c perf mem: Allow all record/report options 2018-04-18 15:35:48 -03:00
builtin-probe.c perf probe: Avoid calling freeing routine multiple times for same pointer 2019-08-16 10:12:48 +02:00
builtin-record.c perf record: Synthesize features before events in pipe mode 2018-03-16 13:56:50 -03:00
builtin-report.c perf evsel: Store ids for events with their own cpus perf_event__synthesize_event_update_cpus 2018-10-16 08:18:52 -03:00
builtin-sched.c perf sched: Use sched->show_callchain where appropriate 2018-06-05 10:09:54 -03:00
builtin-script.c perf script: Fix crash when processing recorded stat data 2019-03-13 14:02:26 -07:00
builtin-stat.c perf stat: Fix use-after-freed pointer detected by the smatch tool 2019-07-31 07:27:06 +02:00
builtin-timechart.c perf tools: Add missing open_memstream() prototype for systems lacking it 2019-01-26 09:32:41 +01:00
builtin-top.c perf top: Fix potential NULL pointer dereference detected by the smatch tool 2019-07-31 07:27:06 +02:00
builtin-trace.c perf trace: Support multiple "vfs_getname" probes 2019-03-13 14:02:37 -07:00
builtin-version.c perf version: Fix segfault due to missing OPT_END() 2019-08-06 19:06:50 +02:00
builtin.h
check-headers.sh tools include: Adopt linux/bits.h 2019-04-27 09:36:40 +02:00
command-list.txt
CREDITS
design.txt
Makefile perf tools: Disable parallelism for 'make clean' 2018-08-20 08:54:58 -03:00
Makefile.config perf build: Don't unconditionally link the libbfd feature test to -liberty and -lz 2019-02-12 19:47:16 +01:00
Makefile.perf perf tools: Pass build flags to traceevent build 2018-10-16 14:57:59 -03:00
MANIFEST
perf-archive.sh
perf-completion.sh
perf-read-vdso.c
perf-sys.h Drop a bunch of metag references 2018-02-23 14:29:59 +00:00
perf-with-kcore.sh
perf.c perf tools: Remove dead quote.[ch] code 2018-06-04 10:28:50 -03:00
perf.h perf tools: Increase MAX_NR_CPUS and MAX_CACHES 2019-07-26 09:14:12 +02:00