diff options
author | Hendrik Brueckner <brueckner@linux.ibm.com> | 2018-05-03 15:56:15 +0200 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-10-21 08:45:57 +0100 |
commit | cdb39e45062e5916358aa23915391adbac81fb27 (patch) | |
tree | d1c0e774eab6a50ecdd63090cc2dcd8758c2f33d /arch/s390/kernel | |
parent | e9423efe8748f830e3a613df5d1d392273dff765 (diff) | |
download | linux-stable-cdb39e45062e5916358aa23915391adbac81fb27.tar.gz linux-stable-cdb39e45062e5916358aa23915391adbac81fb27.tar.bz2 linux-stable-cdb39e45062e5916358aa23915391adbac81fb27.zip |
s390/cpum_sf: ensure sample frequency of perf event attributes is non-zero
commit 4bbaf2584b86b0772413edeac22ff448f36351b1 upstream.
Correct a trinity finding for the perf_event_open() system call with
a perf event attribute structure that uses a frequency but has the
sampling frequency set to zero. This causes a FP divide exception during
the sample rate initialization for the hardware sampling facility.
Fixes: 8c069ff4bd606 ("s390/perf: add support for the CPU-Measurement Sampling Facility")
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'arch/s390/kernel')
-rw-r--r-- | arch/s390/kernel/perf_cpum_sf.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c index ea0c7b2ef030..d56489d26982 100644 --- a/arch/s390/kernel/perf_cpum_sf.c +++ b/arch/s390/kernel/perf_cpum_sf.c @@ -744,6 +744,10 @@ static int __hw_perf_event_init(struct perf_event *event) */ rate = 0; if (attr->freq) { + if (!attr->sample_freq) { + err = -EINVAL; + goto out; + } rate = freq_to_sample_rate(&si, attr->sample_freq); rate = hw_limit_rate(&si, rate); attr->freq = 0; |