mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
s390/perf_cpum_cf: Add missing array_index_nospec() to __hw_perf_event_init()
commit49145bce53upstream. ev variable is userspace controlled via event->attr.config and used as an array index after bounds checking, but without speculation barriers. Add the missing array_index_nospec() call to prevent speculative execution. Cc: stable@vger.kernel.org Fixes:212188a596("[S390] perf: add support for s390x CPU counters") Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com> Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com> Acked-by: Thomas Richter <tmricht@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5be478c1e0
commit
27206bb57c
@@ -17,6 +17,7 @@
|
||||
#include <linux/export.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/perf_event.h>
|
||||
#include <linux/nospec.h>
|
||||
|
||||
#include <asm/cpu_mf.h>
|
||||
#include <asm/hwctrset.h>
|
||||
@@ -766,6 +767,7 @@ static int __hw_perf_event_init(struct perf_event *event, unsigned int type)
|
||||
if (!is_userspace_event(ev)) {
|
||||
if (ev >= ARRAY_SIZE(cpumf_generic_events_user))
|
||||
return -EOPNOTSUPP;
|
||||
ev = array_index_nospec(ev, ARRAY_SIZE(cpumf_generic_events_user));
|
||||
ev = cpumf_generic_events_user[ev];
|
||||
}
|
||||
} else if (!attr->exclude_kernel && attr->exclude_user) {
|
||||
@@ -776,6 +778,7 @@ static int __hw_perf_event_init(struct perf_event *event, unsigned int type)
|
||||
if (!is_userspace_event(ev)) {
|
||||
if (ev >= ARRAY_SIZE(cpumf_generic_events_basic))
|
||||
return -EOPNOTSUPP;
|
||||
ev = array_index_nospec(ev, ARRAY_SIZE(cpumf_generic_events_basic));
|
||||
ev = cpumf_generic_events_basic[ev];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user