Skip to content

Commit 4bbaf25

Browse files
hbruecknerMartin Schwidefsky
authored andcommitted
s390/cpum_sf: ensure sample frequency of perf event attributes is non-zero
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: 8c069ff ("s390/perf: add support for the CPU-Measurement Sampling Facility") Cc: [email protected] # 3.14+ Reviewed-by: Heiko Carstens <[email protected]> Signed-off-by: Hendrik Brueckner <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent de5cb6e commit 4bbaf25

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/s390/kernel/perf_cpum_sf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,10 @@ static int __hw_perf_event_init(struct perf_event *event)
753753
*/
754754
rate = 0;
755755
if (attr->freq) {
756+
if (!attr->sample_freq) {
757+
err = -EINVAL;
758+
goto out;
759+
}
756760
rate = freq_to_sample_rate(&si, attr->sample_freq);
757761
rate = hw_limit_rate(&si, rate);
758762
attr->freq = 0;

0 commit comments

Comments
 (0)