linux/arch/x86/kernel/cpu
Dave Hansen 6ba48ff46f x86: Remove arbitrary instruction size limit in instruction decoder
The current x86 instruction decoder steps along through the
instruction stream but always ensures that it never steps farther
than the largest possible instruction size (MAX_INSN_SIZE).

The MPX code is now going to be doing some decoding of userspace
instructions.  We copy those from userspace in to the kernel and
they're obviously completely untrusted coming from userspace.  In
addition to the constraint that instructions can only be so long,
we also have to be aware of how long the buffer is that came in
from userspace.  This _looks_ to be similar to what the perf and
kprobes is doing, but it's unclear to me whether they are
affected.

The whole reason we need this is that it is perfectly valid to be
executing an instruction within MAX_INSN_SIZE bytes of an
unreadable page. We should be able to gracefully handle short
reads in those cases.

This adds support to the decoder to record how long the buffer
being decoded is and to refuse to "validate" the instruction if
we would have gone over the end of the buffer to decode it.

The kprobes code probably needs to be looked at here a bit more
carefully.  This patch still respects the MAX_INSN_SIZE limit
there but the kprobes code does look like it might be able to
be a bit more strict than it currently is.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Jim Keniston <jkenisto@us.ibm.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: x86@kernel.org
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Link: http://lkml.kernel.org/r/20141114153957.E6B01535@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2014-11-18 00:58:52 +01:00
..
mcheck Merge branch 'for-3.18-consistent-ops' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu 2014-10-15 07:48:18 +02:00
microcode x86, microcode, intel: Rename apply_microcode and declare it static 2014-07-25 17:57:51 +02:00
mtrr x86: Add more disabled features 2014-09-11 14:30:17 -07:00
.gitignore
Makefile perf/x86: Fix compile warnings for intel_uncore 2014-10-28 10:51:03 +01:00
amd.c x86: kvm: use alternatives for VMCALL vs. VMMCALL if kernel text is read-only 2014-09-24 14:07:57 +02:00
bugs.c x86: Get rid of ->hard_math and all the FPU asm fu 2013-06-06 14:32:04 -07:00
bugs_64.c
centaur.c x86: Remove CONFIG_X86_OOSTORE 2014-03-11 10:16:18 -07:00
common.c Merge branch 'for-3.18-consistent-ops' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu 2014-10-15 07:48:18 +02:00
cpu.h x86/cpu: Track legacy CPU model data only on 32-bit kernels 2013-10-26 13:34:39 +02:00
cyrix.c x86: Delete non-required instances of include <linux/init.h> 2014-01-06 21:25:18 -08:00
hypervisor.c x86: Correctly detect hypervisor 2013-08-05 06:35:33 -07:00
intel.c x86: Don't enable F00F workaround on Intel Quark processors 2014-10-29 08:52:09 +01:00
intel_cacheinfo.c arch/x86: replace strict_strto calls 2014-08-08 15:57:28 -07:00
match.c x86: align x86 arch with generic CPU modalias handling 2014-02-18 12:45:38 -08:00
mkcapflags.sh x86/cpufeature: Add bug flags to /proc/cpuinfo 2014-07-14 12:21:39 -07:00
mshyperv.c x86, irq, pic: Probe for legacy PIC and set legacy_pic appropriately 2014-04-14 11:49:55 -07:00
perf_event.c perf/x86/intel: Revert incomplete and undocumented Broadwell client support 2014-10-29 11:07:58 +01:00
perf_event.h perf/x86/intel: Revert incomplete and undocumented Broadwell client support 2014-10-29 11:07:58 +01:00
perf_event_amd.c x86: Replace __get_cpu_var uses 2014-08-26 13:45:49 -04:00
perf_event_amd_ibs.c kprobes, x86: Use NOKPROBE_SYMBOL() instead of __kprobes annotation 2014-04-24 10:26:38 +02:00
perf_event_amd_iommu.c perf/x86/amd: Do not print an error when the device is not present 2013-07-05 08:27:15 +02:00
perf_event_amd_iommu.h perf/x86/amd: AMD IOMMU Performance Counter PERF uncore PMU implementation 2013-06-19 13:04:53 +02:00
perf_event_amd_uncore.c perf/x86/amd: Try to fix some mem allocation failure handling 2014-07-16 13:31:06 +02:00
perf_event_intel.c perf/x86/intel: Revert incomplete and undocumented Broadwell client support 2014-10-29 11:07:58 +01:00
perf_event_intel_ds.c x86: Remove arbitrary instruction size limit in instruction decoder 2014-11-18 00:58:52 +01:00
perf_event_intel_lbr.c x86: Remove arbitrary instruction size limit in instruction decoder 2014-11-18 00:58:52 +01:00
perf_event_intel_rapl.c x86: Replace __get_cpu_var uses 2014-08-26 13:45:49 -04:00
perf_event_intel_uncore.c perf/x86/intel/uncore: Fix minor race in box set up 2014-10-03 06:02:49 +02:00
perf_event_intel_uncore.h perf/x86/intel/uncore: Add Haswell-EP uncore support 2014-09-24 14:48:21 +02:00
perf_event_intel_uncore_nhmex.c perf/x86/uncore: Fix coccinelle warnings 2014-08-13 07:51:09 +02:00
perf_event_intel_uncore_snb.c perf/x86/intel/uncore: Update support for client uncore IMC PMU 2014-09-24 14:48:25 +02:00
perf_event_intel_uncore_snbep.c perf/x86/intel/uncore: Fix PCU filter setup for Sandy/Ivy/Haswell EP 2014-09-24 14:48:24 +02:00
perf_event_knc.c x86: Replace __get_cpu_var uses 2014-08-26 13:45:49 -04:00
perf_event_p4.c x86: Replace __get_cpu_var uses 2014-08-26 13:45:49 -04:00
perf_event_p6.c perf/x86/intel/p6: Add userspace RDPMC quirk for PPro 2014-02-09 13:08:24 +01:00
perfctr-watchdog.c perf/x86: Add support for Intel Xeon-Phi Knights Corner PMU 2012-10-04 13:32:37 +02:00
powerflags.c update AMD powerflags comments 2013-05-28 12:02:10 +02:00
proc.c x86/cpufeature: Add bug flags to /proc/cpuinfo 2014-07-14 12:21:39 -07:00
rdrand.c x86, rdrand: When nordrand is specified, disable RDSEED as well 2014-05-11 20:25:20 -07:00
scattered.c x86/xsaves: Detect xsaves/xrstors feature 2014-05-29 14:24:28 -07:00
topology.c x86: delete __cpuinit usage from all x86 files 2013-07-14 19:36:56 -04:00
transmeta.c x86: Delete non-required instances of include <linux/init.h> 2014-01-06 21:25:18 -08:00
umc.c x86: Delete non-required instances of include <linux/init.h> 2014-01-06 21:25:18 -08:00
vmware.c x86: Correctly detect hypervisor 2013-08-05 06:35:33 -07:00