From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@kernel.org>,
eranian@google.com
Subject: [ 05/26] perf/x86/intel/lbr: Fix LBR filter
Date: Thu, 9 May 2013 15:34:19 -0700 [thread overview]
Message-ID: <20130509223422.997735672@linuxfoundation.org> (raw)
In-Reply-To: <20130509223422.368544659@linuxfoundation.org>
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
commit 6e15eb3ba6c0249c9e8c783517d131b47db995ca upstream.
The LBR 'from' adddress is under full userspace control; ensure
we validate it before reading from it.
Note: is_module_text_address() can potentially be quite
expensive; for those running into that with high overhead
in modules optimize it using an RCU backed rb-tree.
Reported-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: eranian@google.com
Link: http://lkml.kernel.org/r/20130503121256.158211806@chello.nl
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/n/tip-mk8i82ffzax01cnqo829iy1q@git.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/x86/kernel/cpu/perf_event_intel_lbr.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
--- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
@@ -442,8 +442,18 @@ static int branch_type(unsigned long fro
return X86_BR_NONE;
addr = buf;
- } else
- addr = (void *)from;
+ } else {
+ /*
+ * The LBR logs any address in the IP, even if the IP just
+ * faulted. This means userspace can control the from address.
+ * Ensure we don't blindy read any address by validating it is
+ * a known text address.
+ */
+ if (kernel_text_address(from))
+ addr = (void *)from;
+ else
+ return X86_BR_NONE;
+ }
/*
* decoder needs to know the ABI especially
next prev parent reply other threads:[~2013-05-09 22:34 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-09 22:34 [ 00/26] 3.4.45-stable review Greg Kroah-Hartman
2013-05-09 22:34 ` [ 01/26] powerpc: Emulate non privileged DSCR read and write Greg Kroah-Hartman
2013-05-09 22:34 ` [ 02/26] powerpc: fix numa distance for form0 device tree Greg Kroah-Hartman
2013-05-09 22:34 ` [ 03/26] autofs - remove autofs dentry mount check Greg Kroah-Hartman
2013-05-09 22:34 ` [ 04/26] net/eth/ibmveth: Fixup retrieval of MAC address Greg Kroah-Hartman
2013-05-09 22:34 ` Greg Kroah-Hartman [this message]
2013-05-09 22:34 ` [ 06/26] perf/x86/intel/lbr: Demand proper privileges for PERF_SAMPLE_BRANCH_KERNEL Greg Kroah-Hartman
2013-05-09 22:34 ` [ 07/26] xhci: Dont warn on empty ring for suspended devices Greg Kroah-Hartman
2013-05-09 22:34 ` [ 08/26] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Greg Kroah-Hartman
2013-05-09 22:34 ` [ 09/26] ext4: add check for inodes_count overflow in new resize ioctl Greg Kroah-Hartman
2013-05-09 22:34 ` [ 10/26] r8169: fix 8168evl frame padding Greg Kroah-Hartman
2013-05-09 22:34 ` [ 11/26] cpufreq / Longhaul: Disable driver by default Greg Kroah-Hartman
2013-05-09 22:34 ` [ 12/26] drm/i915: Add no-lvds quirk for Fujitsu Esprimo Q900 Greg Kroah-Hartman
2013-05-09 22:34 ` [ 13/26] drm/i915: Fall back to bit banging mode for DVO transmitter detection Greg Kroah-Hartman
2013-05-09 22:34 ` [ 14/26] drm/radeon: dont use get_engine_clock() on APUs Greg Kroah-Hartman
2013-05-09 22:34 ` [ 15/26] drm/radeon/dce6: add missing display reg for tiling setup Greg Kroah-Hartman
2013-05-09 22:34 ` [ 16/26] drm/radeon: properly lock disp in mc_stop/resume for evergreen+ Greg Kroah-Hartman
2013-05-09 22:34 ` [ 17/26] drm/radeon: disable the crtcs in mc_stop (evergreen+) (v2) Greg Kroah-Hartman
2013-05-09 22:34 ` [ 18/26] drm/radeon: add some new SI PCI ids Greg Kroah-Hartman
2013-05-09 22:34 ` [ 19/26] drm/radeon/evergreen+: dont enable HPD interrupts on eDP/LVDS Greg Kroah-Hartman
2013-05-09 22:34 ` [ 20/26] drm/radeon: fix endian bugs in atom_allocate_fb_scratch() Greg Kroah-Hartman
2013-05-09 22:34 ` [ 21/26] drm/radeon: fix possible segfault when parsing pm tables Greg Kroah-Hartman
2013-05-09 22:34 ` [ 22/26] drm/radeon: add new richland pci ids Greg Kroah-Hartman
2013-05-09 22:34 ` [ 23/26] drm/radeon: fix handling of v6 power tables Greg Kroah-Hartman
2013-05-09 22:34 ` [ 24/26] tracing: Fix ftrace_dump() Greg Kroah-Hartman
2013-05-09 22:34 ` [ 25/26] kernel/audit_tree.c: tree will leak memory when failure occurs in audit_trim_trees() Greg Kroah-Hartman
2013-05-09 22:34 ` [ 26/26] x86/mm: account for PGDIR_SIZE alignment Greg Kroah-Hartman
2013-05-10 15:25 ` [ 00/26] 3.4.45-stable review Shuah Khan
2013-05-11 5:20 ` Satoru Takeuchi
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=20130509223422.997735672@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=a.p.zijlstra@chello.nl \
--cc=ak@linux.intel.com \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=stable@vger.kernel.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).