linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] perf/core: fix possible spectre-v1 write
Date: Wed, 11 Jul 2018 06:53:28 +0100	[thread overview]
Message-ID: <20180711055327.5l23y4z7nk4wv7uz@salmiak> (raw)
In-Reply-To: <20180710180607.56624-1-mark.rutland@arm.com>

On Tue, Jul 10, 2018 at 07:06:07PM +0100, Mark Rutland wrote:
> It's possible for userspace to control event_id. Sanitize event_id when
> using it as an array index, to inhibit the potential spectre-v1 write
> gadget.
> 
> This class of issue is also known as CVE-2018-3693, or "bounds check bypass
> store".
> 
> Found by smatch.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> ---
>  kernel/events/core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> For Arm CPUs, more details can be found in the Arm Cache Speculation
> Side-channels whitepaper, available from the Arm security updates site [1].
> 
> Mark.
> 
> [1] https://developer.arm.com/support/arm-security-updates/speculative-processor-vulnerability
> 
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 8f0434a9951a..eece719bd18e 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -8155,6 +8155,7 @@ struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
>  static void sw_perf_event_destroy(struct perf_event *event)
>  {
>  	u64 event_id = event->attr.config;
> +	event_id = array_index_nospec(event_id, PERF_COUNT_SW_MAX);

As the kbuild test robot has pointed out, I've failed to include
<linux/nospec.h> for this to compile.

I'll spin a v2 with that added, and the result tested.

Thanks,
Mark.

      parent reply	other threads:[~2018-07-11  5:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-10 18:06 [PATCH] perf/core: fix possible spectre-v1 write Mark Rutland
2018-07-10 19:01 ` kbuild test robot
2018-07-10 21:02 ` kbuild test robot
2018-07-11  5:53 ` Mark Rutland [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=20180711055327.5l23y4z7nk4wv7uz@salmiak \
    --to=mark.rutland@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@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).