diff options
| author | Alexei Starovoitov <ast@plumgrid.com> | 2014-10-28 18:11:43 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2014-10-30 15:44:37 -0400 |
| commit | e21ab36a80c2e011a14149fecdd654b8b47d3e8c (patch) | |
| tree | 9dbdb42a7a38ec47602aff64c76c74b177a091c7 /lib | |
| parent | 342ded409608f84fe929216efe0ca2d45e2656be (diff) | |
test: bpf: add a testcase reduced from nmap
nmap generates classic BPF programs to filter ARP packets with given target MAC
which triggered a bug in eBPF x64 JIT. The bug was fixed in
commit e0ee9c12157d ("x86: bpf_jit: fix two bugs in eBPF JIT compiler")
This patch is adding a testcase in eBPF instructions (those that
were generated by classic->eBPF converter) to be processed by JIT.
The test is primarily targeting JIT compiler.
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/test_bpf.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/test_bpf.c b/lib/test_bpf.c index 23e070bcf72d..3f167d2eeb94 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c | |||
| @@ -1756,6 +1756,49 @@ static struct bpf_test tests[] = { | |||
| 1756 | { }, | 1756 | { }, |
| 1757 | { { 0, 1 } } | 1757 | { { 0, 1 } } |
| 1758 | }, | 1758 | }, |
| 1759 | { | ||
| 1760 | "nmap reduced", | ||
| 1761 | .u.insns_int = { | ||
| 1762 | BPF_MOV64_REG(R6, R1), | ||
| 1763 | BPF_LD_ABS(BPF_H, 12), | ||
| 1764 | BPF_JMP_IMM(BPF_JNE, R0, 0x806, 28), | ||
| 1765 | BPF_LD_ABS(BPF_H, 12), | ||
| 1766 | BPF_JMP_IMM(BPF_JNE, R0, 0x806, 26), | ||
| 1767 | BPF_MOV32_IMM(R0, 18), | ||
| 1768 | BPF_STX_MEM(BPF_W, R10, R0, -64), | ||
| 1769 | BPF_LDX_MEM(BPF_W, R7, R10, -64), | ||
| 1770 | BPF_LD_IND(BPF_W, R7, 14), | ||
| 1771 | BPF_STX_MEM(BPF_W, R10, R0, -60), | ||
| 1772 | BPF_MOV32_IMM(R0, 280971478), | ||
| 1773 | BPF_STX_MEM(BPF_W, R10, R0, -56), | ||
| 1774 | BPF_LDX_MEM(BPF_W, R7, R10, -56), | ||
| 1775 | BPF_LDX_MEM(BPF_W, R0, R10, -60), | ||
| 1776 | BPF_ALU32_REG(BPF_SUB, R0, R7), | ||
| 1777 | BPF_JMP_IMM(BPF_JNE, R0, 0, 15), | ||
| 1778 | BPF_LD_ABS(BPF_H, 12), | ||
| 1779 | BPF_JMP_IMM(BPF_JNE, R0, 0x806, 13), | ||
| 1780 | BPF_MOV32_IMM(R0, 22), | ||
| 1781 | BPF_STX_MEM(BPF_W, R10, R0, -56), | ||
| 1782 | BPF_LDX_MEM(BPF_W, R7, R10, -56), | ||
| 1783 | BPF_LD_IND(BPF_H, R7, 14), | ||
| 1784 | BPF_STX_MEM(BPF_W, R10, R0, -52), | ||
| 1785 | BPF_MOV32_IMM(R0, 17366), | ||
| 1786 | BPF_STX_MEM(BPF_W, R10, R0, -48), | ||
| 1787 | BPF_LDX_MEM(BPF_W, R7, R10, -48), | ||
| 1788 | BPF_LDX_MEM(BPF_W, R0, R10, -52), | ||
| 1789 | BPF_ALU32_REG(BPF_SUB, R0, R7), | ||
| 1790 | BPF_JMP_IMM(BPF_JNE, R0, 0, 2), | ||
| 1791 | BPF_MOV32_IMM(R0, 256), | ||
| 1792 | BPF_EXIT_INSN(), | ||
| 1793 | BPF_MOV32_IMM(R0, 0), | ||
| 1794 | BPF_EXIT_INSN(), | ||
| 1795 | }, | ||
| 1796 | INTERNAL, | ||
| 1797 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x06, 0, 0, | ||
| 1798 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1799 | 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6}, | ||
| 1800 | { { 38, 256 } } | ||
| 1801 | }, | ||
| 1759 | }; | 1802 | }; |
| 1760 | 1803 | ||
| 1761 | static struct net_device dev; | 1804 | static struct net_device dev; |
