diff options
author | Ilya Leoshkevich <iii@linux.ibm.com> | 2021-09-07 11:58:59 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-09-22 12:28:02 +0200 |
commit | ab7cf225016159bc2c3590be6fa12965565d903b (patch) | |
tree | 4c3667103d50c97624a0d846064e2c381e53a014 | |
parent | 4320c222c2ffe778a8aff5b8bc4ac33af6d54eba (diff) | |
download | linux-stable-ab7cf225016159bc2c3590be6fa12965565d903b.tar.gz linux-stable-ab7cf225016159bc2c3590be6fa12965565d903b.tar.bz2 linux-stable-ab7cf225016159bc2c3590be6fa12965565d903b.zip |
s390/bpf: Fix branch shortening during codegen pass
commit 1511df6f5e9ef32826f20db2ee81f8527154dc14 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: 4e9b4a6883dd ("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>
-rw-r--r-- | arch/s390/net/bpf_jit_comp.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index cba6e9825fb8..8d9047d2d1e1 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c @@ -248,8 +248,7 @@ static inline void reg_set_seen(struct bpf_jit *jit, u32 b1) #define EMIT6_PCREL(op1, op2, b1, b2, i, off, mask) \ ({ \ - /* Branch instruction needs 6 bytes */ \ - int rel = (addrs[(i) + (off) + 1] - (addrs[(i) + 1] - 6)) / 2;\ + int rel = (addrs[(i) + (off) + 1] - jit->prg) / 2; \ _EMIT6((op1) | reg(b1, b2) << 16 | (rel & 0xffff), (op2) | (mask));\ REG_SET_SEEN(b1); \ REG_SET_SEEN(b2); \ |