LKML Archive on lore.kernel.org
 help / color / Atom feed
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 3/7] perf,x86: Fix possible Spectre-v1 for x86_pmu::event_map()
Date: Fri, 20 Apr 2018 15:14:10 +0200
Message-ID: <20180420131631.823785261@infradead.org> (raw)
In-Reply-To: <20180420131407.721875616@infradead.org>

[-- Attachment #0: peterz-spectre1-3.patch --]
[-- Type: text/plain, Size: 1098 bytes --]

> arch/x86/events/intel/core.c:337 intel_pmu_event_map() warn: potential spectre issue 'intel_perfmon_event_map'
> arch/x86/events/intel/knc.c:122 knc_pmu_event_map() warn: potential spectre issue 'knc_perfmon_event_map'
> arch/x86/events/intel/p4.c:722 p4_pmu_event_map() warn: potential spectre issue 'p4_general_events'
> arch/x86/events/intel/p6.c:116 p6_pmu_event_map() warn: potential spectre issue 'p6_perfmon_event_map'
> arch/x86/events/amd/core.c:132 amd_pmu_event_map() warn: potential spectre issue 'amd_perfmon_event_map'

Userspace controls @attr, sanitize @attr->config before passing it on
to x86_pmu::event_map().

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
 arch/x86/events/core.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -424,6 +424,8 @@ int x86_setup_perfctr(struct perf_event
 	if (attr->config >= x86_pmu.max_events)
 		return -EINVAL;
 
+	attr->config = array_index_nospec(attr->config, x86_pmu.max_events);
+
 	/*
 	 * The generic map:
 	 */

  parent reply index

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 ` Peter Zijlstra [this message]
2018-04-20 13:14 ` [PATCH 4/7] perf,x86/msr: Fix possible Spectre-v1 for msr Peter Zijlstra
2018-04-20 13:14 ` [PATCH 5/7] perf,x86/cstate: Fix possible Spectre-v1 for pkg_msr Peter Zijlstra
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 publically 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.823785261@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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox