linux-stable/tools
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
..
accounting
arch jump_label: move 'asm goto' support test to Kconfig 2019-06-04 08:02:34 +02:00
bpf tools: bpftool: Fix json dump crash on powerpc 2019-07-26 09:14:16 +02:00
build perf build: Don't unconditionally link the libbfd feature test to -liberty and -lz 2019-02-12 19:47:16 +01:00
cgroup
firewire
gpio
hv Tools: hv: kvp: Fix a warning of buffer overflow with gcc 8.0.1 2019-02-12 19:46:59 +01:00
iio iio: iio-utils: Fix possible incorrect mask calculation 2019-07-31 07:27:02 +02:00
include bpf: fix uapi bpf_prog_info fields alignment 2019-07-26 09:14:15 +02:00
kvm/kvm_stat tools/kvm_stat: fix fields filter for child events 2019-06-19 08:18:05 +02:00
laptop
leds
lib bpf, libbpf, smatch: Fix potential NULL pointer dereference 2019-07-26 09:14:15 +02:00
memory-model tools/memory-model: Rename litmus tests to comply to norm7 2018-07-17 09:30:36 +02:00
nfsd
objtool objtool: Support GCC 9 cold subfunction naming scheme 2019-08-06 19:06:57 +02:00
pci tools: PCI: Add MSI-X support 2018-07-19 11:47:13 +01:00
pcmcia
perf perf header: Fix use of unitialized value warning 2019-08-25 10:47:53 +02:00
power cpupower : frequency-set -r option misses the last cpu in related cpu list 2019-07-26 09:14:03 +02:00
scripts
spi
testing cgroup: kselftest: relax fs_spec checks 2019-08-06 19:06:55 +02:00
thermal/tmon
time
usb usbip: fix vhci_hcd controller counting 2019-04-20 09:16:01 +02:00
virtio virtio: fix test build after uio.h change 2019-01-13 09:51:03 +01:00
vm tools/vm/page-types.c: fix "defined but not used" warning 2018-09-04 16:45:02 -07:00
wmi
Makefile