[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2fbdf14a9e87d240411a420550cf8f797eac3f8c.camel@linux.ibm.com>
Date: Thu, 15 Jul 2021 19:02:01 +0200
From: Ilya Leoshkevich <iii@...ux.ibm.com>
To: Colin King <colin.king@...onical.com>,
Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ibm.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Michael Holzheu <holzheu@...ux.vnet.ibm.com>,
Martin Schwidefsky <schwidefsky@...ibm.com>,
netdev@...r.kernel.org, bpf@...r.kernel.org,
linux-s390@...r.kernel.org
Cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] s390/bpf: perform r1 range checking before accessing
jit->seen_reg[r1]
On Thu, 2021-07-15 at 13:57 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@...onical.com>
>
> 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: 054623105728 ("s390/bpf: Add s390x eBPF JIT compiler backend")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
> arch/s390/net/bpf_jit_comp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/s390/net/bpf_jit_comp.c
> b/arch/s390/net/bpf_jit_comp.c
> index 63cae0476bb4..2ae419f5115a 100644
> --- a/arch/s390/net/bpf_jit_comp.c
> +++ b/arch/s390/net/bpf_jit_comp.c
> @@ -112,7 +112,7 @@ static inline void reg_set_seen(struct bpf_jit
> *jit, u32 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;
> }
>
Looks good to me, thanks!
Acked-by: Ilya Leoshkevich <iii@...ux.ibm.com>
Tested-by: Ilya Leoshkevich <iii@...ux.ibm.com>
Powered by blists - more mailing lists