]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
s390/bpf: Tolerate not converging code shrinking
authorIlya Leoshkevich <iii@linux.ibm.com>
Fri, 17 Jul 2020 16:53:25 +0000 (18:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Aug 2020 06:23:59 +0000 (08:23 +0200)
commitff3e1a7d43e8f06aa839ac5f6b0c742750054b73
treeb32569424421707fa738c043e03e7401ed8a2e53
parentb5f48c957f335c8d97fd554fd08c73f6dbfb001a
s390/bpf: Tolerate not converging code shrinking

[ Upstream commit 1491b73311a15bb5beeab5d30e03bff761ef6c18 ]

"BPF_MAXINSNS: Maximum possible literals" unnecessarily falls back to
the interpreter because of failing sanity check in bpf_set_addr. The
problem is that there are a lot of branches that can be shrunk, and
doing so opens up the possibility to shrink even more. This process
does not converge after 3 passes, causing code offsets to change during
the codegen pass, which must never happen.

Fix by inserting nops during codegen pass in order to preserve code
offets.

Fixes: 4e9b4a6883dd ("s390/bpf: Use relative long branches")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200717165326.6786-5-iii@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/s390/net/bpf_jit_comp.c