+65
−17
Loading
The "Read backward ring buffer" test crashes on big-endian (e.g. s390x) due to a NULL dereference when the backward mmap path isn't enabled. Reproducer: # ./perf test -F 'Read backward ring buffer' Segmentation fault (core dumped) # uname -m s390x # Root cause: get_config_terms() stores into evsel_config_term::val.val (u64) while later code reads boolean fields such as evsel_config_term::val.overwrite. On big-endian the 1-byte boolean is left-aligned, so writing evsel_config_term::val.val = 1 is read back as evsel_config_term::val.overwrite = 0, leaving backward mmap disabled and a NULL map being used. Store values in the union member that matches the term type, e.g.: /* for OVERWRITE */ new_term->val.overwrite = 1; /* not new_term->val.val = 1 */ to fix this. Improve add_config_term() and add two more parameters for string and value. Function add_config_term() now creates a complete node element of type evsel_config_term and handles all evsel_config_term::val union members. Impact: Enables backward mmap on big-endian and prevents the crash. No change on little-endian. Output after: # ./perf test -Fv 44 --- start --- Using CPUID IBM,9175,705,ME1,3.8,002f mmap size 1052672B mmap size 8192B ---- end ---- 44: Read backward ring buffer : Ok # Fixes: 159ca97c ("perf parse-events: Refactor get_config_terms() to remove macros") Reviewed-by:James Clark <james.clark@linaro.org> Reviewed-by:
Jan Polensky <japo@linux.ibm.com> Signed-off-by:
Thomas Richter <tmricht@linux.ibm.com> Acked-by:
Ian Rogers <irogers@google.com> Cc: James Clark <james.clark@linaro.org> Signed-off-by:
Namhyung Kim <namhyung@kernel.org> Signed-off-by:
Arnaldo Carvalho de Melo <acme@redhat.com>