Skip to content

Commit a03ffcf

Browse files
Markus Kötterdavem330
authored andcommitted
net: bpf_jit: fix an off-one bug in x86_64 cond jump target
x86 jump instruction size is 2 or 5 bytes (near/long jump), not 2 or 6 bytes. In case a conditional jump is followed by a long jump, conditional jump target is one byte past the start of target instruction. Signed-off-by: Markus Kötter <nepenthesdev@gmail.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d1388da commit a03ffcf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎arch/x86/net/bpf_jit_comp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
568568
break;
569569
}
570570
if (filter[i].jt != 0) {
571-
if (filter[i].jf)
572-
t_offset += is_near(f_offset) ? 2 : 6;
571+
if (filter[i].jf && f_offset)
572+
t_offset += is_near(f_offset) ? 2 : 5;
573573
EMIT_COND_JMP(t_op, t_offset);
574574
if (filter[i].jf)
575575
EMIT_JMP(f_offset);

0 commit comments

Comments
 (0)