kernel-ark/arch/arm
Daniel Borkmann e8b56d55a3 net: bpf: arm: make hole-faulting more robust
Will Deacon pointed out, that the currently used opcode for filling holes,
that is 0xe7ffffff, seems not robust enough ...

  $ echo 0xffffffe7 | xxd -r > test.bin
  $ arm-linux-gnueabihf-objdump -m arm -D -b binary test.bin
  ...
  0: e7ffffff     udf    #65535  ; 0xffff

... while for Thumb, it ends up as ...

  0: ffff e7ff    vqshl.u64  q15, <illegal reg q15.5>, #63

... which is a bit fragile. The ARM specification defines some *permanently*
guaranteed undefined instruction (UDF) space, for example for ARM in ARMv7-AR,
section A5.4 and for Thumb in ARMv7-M, section A5.2.6.

Similarly, ptrace, kprobes, kgdb, bug and uprobes make use of such instruction
as well to trap. Given mentioned section from the specification, we can find
such a universe as (where 'x' denotes 'don't care'):

  ARM:    xxxx 0111 1111 xxxx xxxx xxxx 1111 xxxx
  Thumb:  1101 1110 xxxx xxxx

We therefore should use a more robust opcode that fits both. Russell King
suggested that we can even reuse a single 32-bit word, that is, 0xe7fddef1
which will fault if executed in ARM *or* Thumb mode as done in f928d4f2a8
("ARM: poison the vectors page"). That will still hold our requirements:

  $ echo 0xf1defde7 | xxd -r > test.bin
  $ arm-unknown-linux-gnueabi-objdump -m arm -D -b binary test.bin
  ...
  0: e7fddef1     udf    #56801 ; 0xdde1
  $ echo 0xf1defde7f1defde7f1defde7 | xxd -r > test.bin
  $ arm-unknown-linux-gnueabi-objdump -marm -Mforce-thumb -D -b binary test.bin
  ...
  0: def1         udf    #241 ; 0xf1
  2: e7fd         b.n    0x0
  4: def1         udf    #241 ; 0xf1
  6: e7fd         b.n    0x4
  8: def1         udf    #241 ; 0xf1
  a: e7fd         b.n    0x8

So on ARM 0xe7fddef1 conforms to the above UDF pattern, and the low 16 bit
likewise correspond to UDF in Thumb case. The 0xe7fd part is an unconditional
branch back to the UDF instruction.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mircea Gherzan <mgherzan@gmail.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-09-23 12:40:22 -04:00
..
boot Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2014-09-23 12:09:27 -04:00
common ARM: edma: Fix configuration parsing for SoCs with multiple eDMA3 CC 2014-08-26 14:49:15 +05:30
configs ARM: SoC defconfig updates for 3.17 2014-08-08 11:35:11 -07:00
crypto Merge branch 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm 2014-08-05 10:05:29 -07:00
firmware
include Merge branch 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm 2014-09-21 12:11:52 -07:00
kernel ARM: 8149/1: perf: Don't sleep while atomic when enabling per-cpu interrupts 2014-09-16 16:09:33 +01:00
kvm arm/arm64: KVM: Complete WFI/WFE instructions 2014-08-29 11:53:53 +02:00
lib ARM: 8137/1: fix get_user BE behavior for target variable with size of 8 bytes 2014-09-12 17:38:59 +01:00
mach-at91 ARM: at91: rm9200: fix clock registration 2014-09-05 17:35:47 +02:00
mach-axxia
mach-bcm ARM: brcmstb: revert SMP support 2014-08-25 18:46:31 -07:00
mach-berlin
mach-clps711x ARM: SoC cleanups for 3.17 2014-08-08 11:00:26 -07:00
mach-cns3xxx
mach-davinci ARM: convert all "mov.* pc, reg" to "bx reg" for ARMv6+ 2014-07-18 12:29:04 +01:00
mach-dove
mach-ebsa110 ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-efm32
mach-ep93xx ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-exynos ARM: 8129/1: errata: work around Cortex-A15 erratum 830321 using dummy strex 2014-08-27 15:40:13 +01:00
mach-footbridge ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-gemini
mach-highbank PM / OPP: Remove ARCH_HAS_OPP 2014-07-23 00:51:30 +02:00
mach-hisi ARM: hisi: remove smp from machine descriptor 2014-07-30 22:32:21 -07:00
mach-imx ARM: imx: correct gpu2d_axi and gpu3d_axi clock setting 2014-08-18 15:05:22 +08:00
mach-integrator ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-iop13xx ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-iop32x
mach-iop33x
mach-ixp4xx
mach-keystone
mach-ks8695 ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-lpc32xx
mach-mediatek arm: add basic support for Mediatek MT6589 boards 2014-07-22 17:52:37 +02:00
mach-mmp
mach-moxart
mach-msm Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2014-08-06 21:03:53 -07:00
mach-mv78xx0
mach-mvebu ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-mxs
mach-netx
mach-nomadik
mach-nspire
mach-omap1 ARM: SoC cleanups for 3.17 2014-08-08 11:00:26 -07:00
mach-omap2 ARM: OMAP2+: gpmc: Don't complain if wait pin is used without r/w monitoring 2014-09-04 12:39:22 -07:00
mach-orion5x
mach-picoxcell
mach-prima2
mach-pxa Merge branch 'akpm' (second patchbomb from Andrew Morton) 2014-08-08 15:57:47 -07:00
mach-qcom
mach-realview ARM: SoC cleanups for 3.17 2014-08-08 11:00:26 -07:00
mach-rockchip ARM: SoC device-tree changes for 3.17 2014-08-08 11:16:58 -07:00
mach-rpc ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-s3c24xx Merge branch 'akpm' (second patchbomb from Andrew Morton) 2014-08-08 15:57:47 -07:00
mach-s3c64xx ARM: SAMSUNG: Remove legacy clock code 2014-07-19 04:24:59 +09:00
mach-s5pv210 ARM: SoC cleanups for 3.17 2014-08-08 11:00:26 -07:00
mach-sa1100 ARM: 8113/1: remove remaining definitions of PLAT_PHYS_OFFSET from <mach/memory.h> 2014-07-29 23:08:52 +01:00
mach-shmobile Renesas ARM Based SoC Clock Fixes For v3.17 2014-08-27 15:14:05 -07:00
mach-socfpga
mach-spear ARM: SoC driver changes for 3.17 2014-08-08 11:34:32 -07:00
mach-sti
mach-sunxi ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-tegra This is the bulk of GPIO changes for the v3.17 development 2014-08-08 18:00:35 -07:00
mach-u300
mach-ux500
mach-versatile ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
mach-vexpress vexpress/spc: fix a build warning on array bounds 2014-08-31 10:22:10 -07:00
mach-vt8500
mach-w90x900 arch/arm/mach-w90x900/cpu.c: replace obsolete strict_strto 2014-08-08 15:57:28 -07:00
mach-zynq PM / OPP: Remove ARCH_HAS_OPP 2014-07-23 00:51:30 +02:00
mm ARM: 8132/1: LPAE: drop wrong carry flag correction after adding TTBR1_OFFSET 2014-09-02 20:55:23 +01:00
net net: bpf: arm: make hole-faulting more robust 2014-09-23 12:40:22 -04:00
nwfpe ARM: convert all "mov.* pc, reg" to "bx reg" for ARMv6+ 2014-07-18 12:29:04 +01:00
oprofile Merge branch 'devel-stable' into for-next 2014-08-05 10:27:25 +01:00
plat-iop
plat-omap ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
plat-orion dsa: Replace mii_bus with a generic host device 2014-09-15 17:24:20 -04:00
plat-pxa
plat-samsung Merge branch 'cleanup/gpio-header-removal' into next/soc 2014-07-26 18:00:40 +02:00
plat-versatile
tools
vfp ARM: convert all "mov.* pc, reg" to "bx reg" for ARMv6+ 2014-07-18 12:29:04 +01:00
xen xen/arm: remove mach_to_phys rbtree 2014-09-11 18:11:53 +00:00
Kconfig kexec: remove CONFIG_KEXEC dependency on crypto 2014-08-29 16:28:16 -07:00
Kconfig-nommu
Kconfig.debug ARM: SoC device-tree changes for 3.17 2014-08-08 11:16:58 -07:00
Makefile ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00