]> asedeno.scripts.mit.edu Git - linux.git/commit
bpf, x32: Fix bug for BPF_ALU64 | BPF_NEG
authorWang YanQing <udknight@gmail.com>
Sun, 28 Apr 2019 02:33:02 +0000 (10:33 +0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 1 May 2019 21:40:47 +0000 (23:40 +0200)
commitb9aa0b35d878dff9ed19f94101fe353a4de00cc4
treea0e484e108a504acf6b26789acdd9d8cce5df756
parent711aef1bbf88212a21f7103e88f397b47a528805
bpf, x32: Fix bug for BPF_ALU64 | BPF_NEG

The current implementation has two errors:

1: The second xor instruction will clear carry flag which
   is necessary for following sbb instruction.
2: The select coding for sbb instruction is wrong, the coding
   is "sbb dreg_hi,ecx", but what we need is "sbb ecx,dreg_hi".

This patch rewrites the implementation and fixes the errors.

This patch fixes below errors reported by bpf/test_verifier in x32
platform when the jit is enabled:

"
0: (b4) w1 = 4
1: (b4) w2 = 4
2: (1f) r2 -= r1
3: (4f) r2 |= r1
4: (87) r2 = -r2
5: (c7) r2 s>>= 63
6: (5f) r1 &= r2
7: (bf) r0 = r1
8: (95) exit
processed 9 insns (limit 131072), stack depth 0
0: (b4) w1 = 4
1: (b4) w2 = 4
2: (1f) r2 -= r1
3: (4f) r2 |= r1
4: (87) r2 = -r2
5: (c7) r2 s>>= 63
6: (5f) r1 &= r2
7: (bf) r0 = r1
8: (95) exit
processed 9 insns (limit 131072), stack depth 0
......
Summary: 1189 PASSED, 125 SKIPPED, 15 FAILED
"

Signed-off-by: Wang YanQing <udknight@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
arch/x86/net/bpf_jit_comp32.c