]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libcpu: Recognize bpf jump variants BPF_JLT, BPF_JLE, BPF_JSLT and BPF_JSLE
authorMark Wielaard <mark@klomp.org>
Sun, 4 Nov 2018 20:34:38 +0000 (21:34 +0100)
committerMark Wielaard <mark@klomp.org>
Fri, 9 Nov 2018 17:26:38 +0000 (18:26 +0100)
Linux kernel 4.13 introduced 4 more jump class variants.

  commit 92b31a9af73b3a3fc801899335d6c47966351830
  Author: Daniel Borkmann <daniel@iogearbox.net>
  Date:   Thu Aug 10 01:39:55 2017 +0200

    bpf: add BPF_J{LT,LE,SLT,SLE} instructions

For conditional jumping on unsigned and signed < and <= between a register
and another register or immediate.

Add these new constants to bpf.h, recognize them in bpf_disasm and update
the testfile-bpf-dis1.expect file.

Signed-off-by: Mark Wielaard <mark@klomp.org>
lib/ChangeLog
lib/bpf.h
libcpu/ChangeLog
libcpu/bpf_disasm.c
tests/ChangeLog
tests/testfile-bpf-dis1.expect.bz2

index 86a53d2c2cd0f0ccb9540804b3c4839306587756..0914b2c6e6ce907378b4bd9e39bfc7bf00758cf1 100644 (file)
@@ -1,3 +1,7 @@
+2018-11-04  Mark Wielaard  <mark@klomp.org>
+
+       * bpf.h: Add BPF_JLT, BPF_JLE, BPF_JSLT and BPF_JSLE.
+
 2018-07-04  Ross Burton <ross.burton@intel.com>
 
        * color.c: Remove error.h, add system.h include.
index db80a51eb5c496e16d70b6784171060f1d8681ff..efb26f8f18c1f5828e697a5344a17e3142f9233c 100644 (file)
--- a/lib/bpf.h
+++ b/lib/bpf.h
 #define BPF_JSGE 0x70
 #define BPF_CALL 0x80
 #define BPF_EXIT 0x90
+#define BPF_JLT  0xa0
+#define BPF_JLE  0xb0
+#define BPF_JSLT 0xc0
+#define BPF_JSLE 0xd0
 
 #define BPF_W 0x00
 #define BPF_H 0x08
index 86d294782247abee851e2595a3ea3a8528ac6c64..adebbef85b653fd6fe608a31aafbde16edc1a607 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-04  Mark Wielaard  <mark@klomp.org>
+
+       * bpf_disasm.c (bpf_disasm): Recognize BPF_JLT, BPF_JLE, BPF_JSLT
+       and BPF_JSLE.
+
 2018-02-09  Joshua Watt  <JPEWhacker@gmail.com>
 
        * i386_disasm.c (i386_disasm): Use FALLTHOUGH macro instead of
index 054aba2bb05ca8ade920f769480b6ee991422a82..3d92d014ca7b219377e341f92b8af7eb639f7a6c 100644 (file)
@@ -1,5 +1,5 @@
 /* Disassembler for BPF.
-   Copyright (C) 2016 Red Hat, Inc.
+   Copyright (C) 2016, 2018 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -346,6 +346,18 @@ bpf_disasm (Ebl *ebl, const uint8_t **startp, const uint8_t *end,
        case BPF_JMP | BPF_JSGE | BPF_K:
          code_fmt = J64(REGS(1), >=, IMMS(2));
          goto do_dst_imm_jmp;
+       case BPF_JMP | BPF_JLT | BPF_K:
+         code_fmt = J64(REG(1), <, IMMS(2));
+         goto do_dst_imm_jmp;
+       case BPF_JMP | BPF_JLE | BPF_K:
+         code_fmt = J64(REG(1), <=, IMMS(2));
+         goto do_dst_imm_jmp;
+       case BPF_JMP | BPF_JSLT | BPF_K:
+         code_fmt = J64(REGS(1), <, IMMS(2));
+         goto do_dst_imm_jmp;
+       case BPF_JMP | BPF_JSLE | BPF_K:
+         code_fmt = J64(REGS(1), <=, IMMS(2));
+         goto do_dst_imm_jmp;
 
        case BPF_JMP | BPF_JEQ | BPF_X:
          code_fmt = J64(REG(1), ==, REG(2));
@@ -368,6 +380,18 @@ bpf_disasm (Ebl *ebl, const uint8_t **startp, const uint8_t *end,
        case BPF_JMP | BPF_JSGE | BPF_X:
          code_fmt = J64(REGS(1), >=, REGS(2));
          goto do_dst_src_jmp;
+       case BPF_JMP | BPF_JLT | BPF_X:
+         code_fmt = J64(REG(1), <, REG(2));
+         goto do_dst_src_jmp;
+       case BPF_JMP | BPF_JLE | BPF_X:
+         code_fmt = J64(REG(1), <=, REG(2));
+         goto do_dst_src_jmp;
+       case BPF_JMP | BPF_JSLT | BPF_X:
+         code_fmt = J64(REGS(1), <, REGS(2));
+         goto do_dst_src_jmp;
+       case BPF_JMP | BPF_JSLE | BPF_X:
+         code_fmt = J64(REGS(1), <=, REGS(2));
+         goto do_dst_src_jmp;
 
        case BPF_LDX | BPF_MEM | BPF_B:
          code_fmt = LOAD(u8);
index b0da4c79c52e20ee3db57b9da1f6a281f0eb27ee..92dfb95d7000a6eeb66b2580644dec1e06b1b21d 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-04  Mark Wielaard  <mark@klomp.org>
+
+       * testfile-bpf-reloc.expect.bz2: Update with new expected jump
+       variants.
+
 2018-10-20  Mark Wielaard  <mark@klomp.org>
 
        * run-readelf-compressed.sh: New test.
index 21b55e94431e96914d38ad86683b54f29c58c617..61a8afb1f7a06ab2ad261d7c60e1b330611310a2 100644 (file)
Binary files a/tests/testfile-bpf-dis1.expect.bz2 and b/tests/testfile-bpf-dis1.expect.bz2 differ