1. 09 8月, 2019 3 次提交
  2. 02 8月, 2019 3 次提交
    • A
      selftests/bpf: tests for jmp to 1st insn · f1fc7249
      Alexei Starovoitov 提交于
      Add 2 tests that check JIT code generation to jumps to 1st insn.
      1st test is similar to syzbot reproducer.
      The backwards branch is never taken at runtime.
      2nd test has branch to 1st insn that executes.
      The test is written as two bpf functions, since it's not possible
      to construct valid single bpf program that jumps to 1st insn.
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      f1fc7249
    • A
      bpf: fix x64 JIT code generation for jmp to 1st insn · 7c2e988f
      Alexei Starovoitov 提交于
      Introduction of bounded loops exposed old bug in x64 JIT.
      JIT maintains the array of offsets to the end of all instructions to
      compute jmp offsets.
      addrs[0] - offset of the end of the 1st insn (that includes prologue).
      addrs[1] - offset of the end of the 2nd insn.
      JIT didn't keep the offset of the beginning of the 1st insn,
      since classic BPF didn't have backward jumps and valid extended BPF
      couldn't have a branch to 1st insn, because it didn't allow loops.
      With bounded loops it's possible to construct a valid program that
      jumps backwards to the 1st insn.
      Fix JIT by computing:
      addrs[0] - offset of the end of prologue == start of the 1st insn.
      addrs[1] - offset of the end of 1st insn.
      
      v1->v2:
      - Yonghong noticed a bug in jit linfo.
        Fix it by passing 'addrs + 1' to bpf_prog_fill_jited_linfo(),
        since it expects insn_to_jit_off array to be offsets to last byte.
      
      Reported-by: syzbot+35101610ff3e83119b1b@syzkaller.appspotmail.com
      Fixes: 2589726d ("bpf: introduce bounded loops")
      Fixes: 0a14842f ("net: filter: Just In Time compiler for x86-64")
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      7c2e988f
    • A
      libbpf: set BTF FD for prog only when there is supported .BTF.ext data · 3415ec64
      Andrii Nakryiko 提交于
      5d01ab7b ("libbpf: fix erroneous multi-closing of BTF FD")
      introduced backwards-compatibility issue, manifesting itself as -E2BIG
      error returned on program load due to unknown non-zero btf_fd attribute
      value for BPF_PROG_LOAD sys_bpf() sub-command.
      
      This patch fixes bug by ensuring that we only ever associate BTF FD with
      program if there is a BTF.ext data that was successfully loaded into
      kernel, which automatically means kernel supports func_info/line_info
      and associated BTF FD for progs (checked and ensured also by BTF
      sanitization code).
      
      Fixes: 5d01ab7b ("libbpf: fix erroneous multi-closing of BTF FD")
      Reported-by: NAndrey Ignatov <rdna@fb.com>
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      3415ec64
  3. 01 8月, 2019 1 次提交
  4. 27 7月, 2019 7 次提交
  5. 26 7月, 2019 22 次提交
  6. 25 7月, 2019 4 次提交