linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: pawel.moll@arm.com (Pawel Moll)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/5] bus: arm-ccn: Do not attempt to configure XPs for cycle counter
Date: Fri, 12 Aug 2016 17:25:53 +0100	[thread overview]
Message-ID: <1471019156-5485-3-git-send-email-pawel.moll@arm.com> (raw)
In-Reply-To: <1471019156-5485-1-git-send-email-pawel.moll@arm.com>

Fuzzing the CCN perf driver revealed a small but definitely dangerous
mistake in the event setup code. When a cycle counter is requested, the
driver should not reconfigure the events bus at all, otherwise it will
corrupt (in most but the simplest cases) its configuration and may end
up accessing XP array out of its bounds.

Reported-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Cc: stable at vger.kernel.org # 3.17+
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
 drivers/bus/arm-ccn.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
index a11b9bb..9bbb0ab 100644
--- a/drivers/bus/arm-ccn.c
+++ b/drivers/bus/arm-ccn.c
@@ -897,6 +897,10 @@ static void arm_ccn_pmu_xp_dt_config(struct perf_event *event, int enable)
 	struct arm_ccn_component *xp;
 	u32 val, dt_cfg;
 
+	/* Nothing to do for cycle counter */
+	if (hw->idx == CCN_IDX_PMU_CYCLE_COUNTER)
+		return;
+
 	if (CCN_CONFIG_TYPE(event->attr.config) == CCN_TYPE_XP)
 		xp = &ccn->xp[CCN_CONFIG_XP(event->attr.config)];
 	else
-- 
2.7.4

  parent reply	other threads:[~2016-08-12 16:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12 16:25 [PATCH 0/5] CCN fixes for 4.8 Pawel Moll
2016-08-12 16:25 ` [PATCH 1/5] bus: arm-ccn: Fix PMU handling of MN Pawel Moll
2016-08-12 16:25 ` Pawel Moll [this message]
2016-08-12 16:25 ` [PATCH 3/5] bus: arm-ccn: Fix XP watchpoint settings bitmask Pawel Moll
2016-08-12 16:25 ` [PATCH 4/5] bus: arm-ccn: Correct required arguments for XP PMU events Pawel Moll
2016-08-12 16:25 ` [PATCH 5/5] bus: arm-ccn: Add missing event attribute exclusions for host/guest Pawel Moll
2016-09-02 14:01 ` [PATCH 0/5] CCN fixes for 4.8 Arnd Bergmann
2016-09-02 14:07   ` Pawel Moll
2016-09-02 14:12     ` Arnd Bergmann

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=1471019156-5485-3-git-send-email-pawel.moll@arm.com \
    --to=pawel.moll@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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).