]> git.baikalelectronics.ru Git - kernel.git/commit
s390/bpf: Perform r1 range checking before accessing jit->seen_reg[r1]
authorColin Ian King <colin.king@canonical.com>
Thu, 15 Jul 2021 12:57:12 +0000 (13:57 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 15 Jul 2021 17:47:25 +0000 (19:47 +0200)
commit4e2156e218fc460bfcc874718b060c8666cba3f3
tree506be8ffce01992886cde96740c4792f6a4679c7
parentc6f92542e0017bd2638002d0c4018edee2c5458b
s390/bpf: Perform r1 range checking before accessing jit->seen_reg[r1]

Currently array jit->seen_reg[r1] is being accessed before the range
checking of index r1. The range changing on r1 should be performed
first since it will avoid any potential out-of-range accesses on the
array seen_reg[] and also it is more optimal to perform checks on r1
before fetching data from the array. Fix this by swapping the order
of the checks before the array access.

Fixes: 9f7ede77bdb9 ("s390/bpf: Add s390x eBPF JIT compiler backend")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Link: https://lore.kernel.org/bpf/20210715125712.24690-1-colin.king@canonical.com
arch/s390/net/bpf_jit_comp.c