s390/bpf: Make sure JIT passes do not increase code size
authorIlya Leoshkevich <iii@linux.ibm.com>
Thu, 14 Nov 2019 15:18:20 +0000 (16:18 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 15 Nov 2019 21:25:54 +0000 (22:25 +0100)
commitfcf35131396ace1339e2ca89b45a6b12eed17105
treee9b48ba5045a3f20f17f25feb4ef9ceed227757f
parentb7b3fc8dd95bc02bd30680da258e09dda55270db
s390/bpf: Make sure JIT passes do not increase code size

The upcoming s390 branch length extension patches rely on "passes do
not increase code size" property in order to consistently choose between
short and long branches. Currently this property does not hold between
the first and the second passes for register save/restore sequences, as
well as various code fragments that depend on SEEN_* flags.

Generate the code during the first pass conservatively: assume register
save/restore sequences have the maximum possible length, and that all
SEEN_* flags are set.

Also refuse to JIT if this happens anyway (e.g. due to a bug), as this
might lead to verifier bypass once long branches are introduced.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20191114151820.53222-1-iii@linux.ibm.com
arch/s390/net/bpf_jit_comp.c