1. 04 5月, 2020 1 次提交
  2. 15 4月, 2020 1 次提交
    • L
      arm, bpf: Fix offset overflow for BPF_MEM BPF_DW · 4178417c
      Luke Nelson 提交于
      This patch fixes an incorrect check in how immediate memory offsets are
      computed for BPF_DW on arm.
      
      For BPF_LDX/ST/STX + BPF_DW, the 32-bit arm JIT breaks down an 8-byte
      access into two separate 4-byte accesses using off+0 and off+4. If off
      fits in imm12, the JIT emits a ldr/str instruction with the immediate
      and avoids the use of a temporary register. While the current check off
      <= 0xfff ensures that the first immediate off+0 doesn't overflow imm12,
      it's not sufficient for the second immediate off+4, which may cause the
      second access of BPF_DW to read/write the wrong address.
      
      This patch fixes the problem by changing the check to
      off <= 0xfff - 4 for BPF_DW, ensuring off+4 will never overflow.
      
      A side effect of simplifying the check is that it now allows using
      negative immediate offsets in ldr/str. This means that small negative
      offsets can also avoid the use of a temporary register.
      
      This patch introduces no new failures in test_verifier or test_bpf.c.
      
      Fixes: c5eae692 ("ARM: net: bpf: improve 64-bit store implementation")
      Fixes: ec19e02b ("ARM: net: bpf: fix LDX instructions")
      Co-developed-by: NXi Wang <xi.wang@gmail.com>
      Signed-off-by: NXi Wang <xi.wang@gmail.com>
      Signed-off-by: NLuke Nelson <luke.r.nels@gmail.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20200409221752.28448-1-luke.r.nels@gmail.com
      4178417c
  3. 09 4月, 2020 1 次提交
  4. 11 12月, 2019 1 次提交
  5. 05 6月, 2019 1 次提交
  6. 25 5月, 2019 1 次提交
  7. 27 1月, 2019 1 次提交
  8. 13 7月, 2018 18 次提交
  9. 30 6月, 2018 1 次提交
  10. 05 6月, 2018 2 次提交
  11. 15 5月, 2018 1 次提交
  12. 04 5月, 2018 1 次提交
  13. 27 1月, 2018 1 次提交
  14. 20 1月, 2018 1 次提交
  15. 18 1月, 2018 8 次提交
    • R
      ARM: net: bpf: clarify tail_call index · 091f0248
      Russell King 提交于
      As per 90caccdd ("bpf: fix bpf_tail_call() x64 JIT"), the index used
      for array lookup is defined to be 32-bit wide. Update a misleading
      comment that suggests it is 64-bit wide.
      
      Fixes: 39c13c20 ("arm: eBPF JIT compiler")
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      091f0248
    • R
      ARM: net: bpf: fix LDX instructions · ec19e02b
      Russell King 提交于
      When the source and destination register are identical, our JIT does not
      generate correct code, which leads to kernel oopses.
      
      Fix this by (a) generating more efficient code, and (b) making use of
      the temporary earlier if we will overwrite the address register.
      
      Fixes: 39c13c20 ("arm: eBPF JIT compiler")
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      ec19e02b
    • R
      ARM: net: bpf: fix register saving · 02088d9b
      Russell King 提交于
      When an eBPF program tail-calls another eBPF program, it enters it after
      the prologue to avoid having complex stack manipulations.  This can lead
      to kernel oopses, and similar.
      
      Resolve this by always using a fixed stack layout, a CPU register frame
      pointer, and using this when reloading registers before returning.
      
      Fixes: 39c13c20 ("arm: eBPF JIT compiler")
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      02088d9b
    • R
      ARM: net: bpf: correct stack layout documentation · 0005e55a
      Russell King 提交于
      The stack layout documentation incorrectly suggests that the BPF JIT
      scratch space starts immediately below BPF_FP. This is not correct,
      so let's fix the documentation to reflect reality.
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      0005e55a
    • R
      ARM: net: bpf: move stack documentation · 70ec3a6c
      Russell King 提交于
      Move the stack documentation towards the top of the file, where it's
      relevant for things like the register layout.
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      70ec3a6c
    • R
      ARM: net: bpf: fix stack alignment · d1220efd
      Russell King 提交于
      As per 2dede2d8 ("ARM EABI: stack pointer must be 64-bit aligned
      after a CPU exception") the stack should be aligned to a 64-bit boundary
      on EABI systems.  Ensure that the eBPF JIT appropraitely aligns the
      stack.
      
      Fixes: 39c13c20 ("arm: eBPF JIT compiler")
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      d1220efd
    • R
      ARM: net: bpf: fix tail call jumps · f4483f2c
      Russell King 提交于
      When a tail call fails, it is documented that the tail call should
      continue execution at the following instruction.  An example tail call
      sequence is:
      
        12: (85) call bpf_tail_call#12
        13: (b7) r0 = 0
        14: (95) exit
      
      The ARM assembler for the tail call in this case ends up branching to
      instruction 14 instead of instruction 13, resulting in the BPF filter
      returning a non-zero value:
      
        178:	ldr	r8, [sp, #588]	; insn 12
        17c:	ldr	r6, [r8, r6]
        180:	ldr	r8, [sp, #580]
        184:	cmp	r8, r6
        188:	bcs	0x1e8
        18c:	ldr	r6, [sp, #524]
        190:	ldr	r7, [sp, #528]
        194:	cmp	r7, #0
        198:	cmpeq	r6, #32
        19c:	bhi	0x1e8
        1a0:	adds	r6, r6, #1
        1a4:	adc	r7, r7, #0
        1a8:	str	r6, [sp, #524]
        1ac:	str	r7, [sp, #528]
        1b0:	mov	r6, #104
        1b4:	ldr	r8, [sp, #588]
        1b8:	add	r6, r8, r6
        1bc:	ldr	r8, [sp, #580]
        1c0:	lsl	r7, r8, #2
        1c4:	ldr	r6, [r6, r7]
        1c8:	cmp	r6, #0
        1cc:	beq	0x1e8
        1d0:	mov	r8, #32
        1d4:	ldr	r6, [r6, r8]
        1d8:	add	r6, r6, #44
        1dc:	bx	r6
        1e0:	mov	r0, #0		; insn 13
        1e4:	mov	r1, #0
        1e8:	add	sp, sp, #596	; insn 14
        1ec:	pop	{r4, r5, r6, r7, r8, sl, pc}
      
      For other sequences, the tail call could end up branching midway through
      the following BPF instructions, or maybe off the end of the function,
      leading to unknown behaviours.
      
      Fixes: 39c13c20 ("arm: eBPF JIT compiler")
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      f4483f2c
    • R
      ARM: net: bpf: avoid 'bx' instruction on non-Thumb capable CPUs · e9062481
      Russell King 提交于
      Avoid the 'bx' instruction on CPUs that have no support for Thumb and
      thus do not implement this instruction by moving the generation of this
      opcode to a separate function that selects between:
      
      	bx	reg
      
      and
      
      	mov	pc, reg
      
      according to the capabilities of the CPU.
      
      Fixes: 39c13c20 ("arm: eBPF JIT compiler")
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      e9062481