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 1/7] perf: Fix possible Spectre-v1 for aux_pages
Date: Fri, 20 Apr 2018 15:14:08 +0200 [thread overview]
Message-ID: <20180420131631.720909184@infradead.org> (raw)
In-Reply-To: 20180420131407.721875616@infradead.org
[-- Attachment #1: peterz-spectre1-1.patch --]
[-- Type: text/plain, Size: 899 bytes --]
> kernel/events/ring_buffer.c:871 perf_mmap_to_page() warn: potential spectre issue 'rb->aux_pages'
Userspace controls @pgoff through the fault address. Sanitize the
array index before doing the array dereference.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
kernel/events/ring_buffer.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -867,8 +867,10 @@ perf_mmap_to_page(struct ring_buffer *rb
return NULL;
/* AUX space */
- if (pgoff >= rb->aux_pgoff)
- return virt_to_page(rb->aux_pages[pgoff - rb->aux_pgoff]);
+ if (pgoff >= rb->aux_pgoff) {
+ int aux_pgoff = array_index_nospec(pgoff - rb->aux_pgoff, rb->aux_nr_pages);
+ return virt_to_page(rb->aux_pages[aux_pgoff]);
+ }
}
return __perf_mmap_to_page(rb, pgoff);
next prev parent reply other threads:[~2018-04-20 13:19 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 ` Peter Zijlstra [this message]
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 ` [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 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.720909184@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).