Skip to content

Commit ab7cf22

Browse files
iii-igregkh
authored andcommitted
s390/bpf: Fix branch shortening during codegen pass
commit 1511df6 upstream. EMIT6_PCREL() macro assumes that the previous pass generated 6 bytes of code, which is not the case if branch shortening took place. Fix by using jit->prg, like all the other EMIT6_PCREL_*() macros. Reported-by: Johan Almbladh <johan.almbladh@anyfinetworks.com> Fixes: 4e9b4a6 ("s390/bpf: Use relative long branches") Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4320c22 commit ab7cf22

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎arch/s390/net/bpf_jit_comp.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ static inline void reg_set_seen(struct bpf_jit *jit, u32 b1)
248248

249249
#define EMIT6_PCREL(op1, op2, b1, b2, i, off, mask) \
250250
({ \
251-
/* Branch instruction needs 6 bytes */ \
252-
int rel = (addrs[(i) + (off) + 1] - (addrs[(i) + 1] - 6)) / 2;\
251+
int rel = (addrs[(i) + (off) + 1] - jit->prg) / 2; \
253252
_EMIT6((op1) | reg(b1, b2) << 16 | (rel & 0xffff), (op2) | (mask));\
254253
REG_SET_SEEN(b1); \
255254
REG_SET_SEEN(b2); \

0 commit comments

Comments
 (0)