mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 23:27:06 +00:00
s390/bpf: Perform r1 range checking before accessing jit->seen_reg[r1]
[ Upstream commit9109165625
] 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:0546231057
("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
264452c975
commit
a4afcf9f5c
1 changed files with 1 additions and 1 deletions
|
@ -117,7 +117,7 @@ static inline void reg_set_seen(struct bpf_jit *jit, u32 b1)
|
||||||
{
|
{
|
||||||
u32 r1 = reg2hex[b1];
|
u32 r1 = reg2hex[b1];
|
||||||
|
|
||||||
if (!jit->seen_reg[r1] && r1 >= 6 && r1 <= 15)
|
if (r1 >= 6 && r1 <= 15 && !jit->seen_reg[r1])
|
||||||
jit->seen_reg[r1] = 1;
|
jit->seen_reg[r1] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue