Skip to content

Commit 541a496

Browse files
Thomas RichterAlexander Gordeev
authored andcommitted
s390/pai: Prevent invalid event number for pai_crypto PMU
The pai_crypto PMU has to check the event number. It has to be in the supported range. This is not the case, the lower limit is not checked. Fix this and obey the lower limit. Fixes: 39d6233 ("s390/pai: add support for cryptography counters") Signed-off-by: Thomas Richter <[email protected]> Suggested-by: Sumanth Korikkar <[email protected]> Reviewed-by: Sumanth Korikkar <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent be857b7 commit 541a496

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/s390/kernel/perf_pai_crypto.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ static int paicrypt_event_init(struct perf_event *event)
193193
/* PAI crypto PMU registered as PERF_TYPE_RAW, check event type */
194194
if (a->type != PERF_TYPE_RAW && event->pmu->type != a->type)
195195
return -ENOENT;
196-
/* PAI crypto event must be valid */
197-
if (a->config > PAI_CRYPTO_BASE + paicrypt_cnt)
196+
/* PAI crypto event must be in valid range */
197+
if (a->config < PAI_CRYPTO_BASE ||
198+
a->config > PAI_CRYPTO_BASE + paicrypt_cnt)
198199
return -EINVAL;
199200
/* Allow only CPU wide operation, no process context for now. */
200201
if (event->hw.target || event->cpu == -1)

0 commit comments

Comments
 (0)