From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>,
Ilya Leoshkevich <iii@linux.ibm.com>,
Thomas Richter <tmricht@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1.y 5/5] s390/perf_cpum_cf: Add missing array_index_nospec() to __hw_perf_event_init()
Date: Thu, 23 Jul 2026 10:19:04 -0400 [thread overview]
Message-ID: <20260723141904.3218096-5-sashal@kernel.org> (raw)
In-Reply-To: <20260723141904.3218096-1-sashal@kernel.org>
From: Sumanth Korikkar <sumanthk@linux.ibm.com>
[ Upstream commit 49145bce539117db4b6e9e83c0e5ef528e361050 ]
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: 212188a596d1 ("[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: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/perf_cpum_cf.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c
index 3e5e88536aa27a..4a2cd39ed38e7f 100644
--- a/arch/s390/kernel/perf_cpum_cf.c
+++ b/arch/s390/kernel/perf_cpum_cf.c
@@ -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>
@@ -633,6 +634,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) {
@@ -643,6 +645,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];
}
}
--
2.53.0
prev parent reply other threads:[~2026-07-23 14:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 12:39 FAILED: patch "[PATCH] s390/perf_cpum_cf: Add missing array_index_nospec() to" failed to apply to 6.1-stable tree gregkh
2026-07-23 14:19 ` [PATCH 6.1.y 1/5] s390/cpum_cf: move cpum_cf_ctrset_size() Sasha Levin
2026-07-23 14:19 ` [PATCH 6.1.y 2/5] s390/cpum_cf: move stccm_avail() Sasha Levin
2026-07-23 14:19 ` [PATCH 6.1.y 3/5] s390/cpum_cf: remove in-kernel counting facility interface Sasha Levin
2026-07-23 14:19 ` [PATCH 6.1.y 4/5] s390/cpum_cf: merge source files for CPU Measurement counter facility Sasha Levin
2026-07-23 14:19 ` Sasha Levin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260723141904.3218096-5-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=gor@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=sumanthk@linux.ibm.com \
--cc=tmricht@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox