From: Peter Zijlstra <peterz@infradead.org>
To: linux-kernel@vger.kernel.org, mingo@kernel.org
Cc: tglx@linutronix.de, dan.j.williams@intel.com,
torvalds@linux-foundation.org,
Dan Carpenter <dan.carpenter@oracle.com>,
"Peter Zijlstra" <peterz@infradead.org>
Subject: [PATCH 5/7] perf,x86/cstate: Fix possible Spectre-v1 for pkg_msr
Date: Fri, 20 Apr 2018 15:14:12 +0200 [thread overview]
Message-ID: <20180420131631.926098428@infradead.org> (raw)
In-Reply-To: 20180420131407.721875616@infradead.org
[-- Attachment #1: peterz-spectre1-5.patch --]
[-- Type: text/plain, Size: 782 bytes --]
> arch/x86/events/intel/cstate.c:307 cstate_pmu_event_init() warn: potential spectre issue 'pkg_msr' (local cap)
Userspace controls @attr, sanitize cfg (attr->config) before using it
to index an array.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
arch/x86/events/intel/cstate.c | 1 +
1 file changed, 1 insertion(+)
--- a/arch/x86/events/intel/cstate.c
+++ b/arch/x86/events/intel/cstate.c
@@ -302,6 +302,7 @@ static int cstate_pmu_event_init(struct
} else if (event->pmu == &cstate_pkg_pmu) {
if (cfg >= PERF_CSTATE_PKG_EVENT_MAX)
return -EINVAL;
+ cfg = array_index_nospec(cfg, PERF_CSTATE_PKG_EVENT_MAX);
if (!pkg_msr[cfg].attr)
return -EINVAL;
event->hw.event_base = pkg_msr[cfg].msr;
next prev parent reply other threads:[~2018-04-20 13:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-20 13:14 [PATCH 0/7] Various Spectre-v1 fixes Peter Zijlstra
2018-04-20 13:14 ` [PATCH 1/7] perf: Fix possible Spectre-v1 for aux_pages Peter Zijlstra
2018-04-20 13:14 ` [PATCH 2/7] perf,x86: Fix possible Spectre-v1 for hw_perf_event Peter Zijlstra
2018-04-20 13:14 ` [PATCH 3/7] perf,x86: Fix possible Spectre-v1 for x86_pmu::event_map() Peter Zijlstra
2018-04-20 13:14 ` [PATCH 4/7] perf,x86/msr: Fix possible Spectre-v1 for msr Peter Zijlstra
2018-04-20 13:14 ` Peter Zijlstra [this message]
2018-04-20 13:14 ` [PATCH 6/7] sched: Fix possible Spectre-v1 for sched_prio_to_weight[] Peter Zijlstra
2018-04-20 13:14 ` [PATCH 7/7] sched,autogroup: Fix possible Spectre-v1 for sched_prio_to_weight Peter Zijlstra
2018-04-23 1:03 ` [PATCH 0/7] Various Spectre-v1 fixes Michal Hocko
2018-04-23 9:33 ` Peter Zijlstra
2018-04-23 13:50 ` Dan Williams
2018-04-23 16:47 ` Michal Hocko
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=20180420131631.926098428@infradead.org \
--to=peterz@infradead.org \
--cc=dan.carpenter@oracle.com \
--cc=dan.j.williams@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).