[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0eb3fe81-973b-1a96-df00-a68c74b84eba@iogearbox.net>
Date: Tue, 14 Apr 2020 21:43:21 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: Luke Nelson <lukenels@...washington.edu>, bpf@...r.kernel.org
Cc: Luke Nelson <luke.r.nels@...il.com>, Xi Wang <xi.wang@...il.com>,
Shubham Bansal <illusionist.neo@...il.com>,
Russell King <linux@...linux.org.uk>,
Alexei Starovoitov <ast@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
Andrii Nakryiko <andriin@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...omium.org>, netdev@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf] arm, bpf: Fix offset overflow for BPF_MEM BPF_DW
On 4/10/20 12:17 AM, Luke Nelson wrote:
> This patch fixes an incorrect check in how immediate memory offsets are
> computed for BPF_DW on arm.
>
> For BPF_LDX/ST/STX + BPF_DW, the 32-bit arm JIT breaks down an 8-byte
> access into two separate 4-byte accesses using off+0 and off+4. If off
> fits in imm12, the JIT emits a ldr/str instruction with the immediate
> and avoids the use of a temporary register. While the current check off
> <= 0xfff ensures that the first immediate off+0 doesn't overflow imm12,
> it's not sufficient for the second immediate off+4, which may cause the
> second access of BPF_DW to read/write the wrong address.
>
> This patch fixes the problem by changing the check to
> off <= 0xfff - 4 for BPF_DW, ensuring off+4 will never overflow.
>
> A side effect of simplifying the check is that it now allows using
> negative immediate offsets in ldr/str. This means that small negative
> offsets can also avoid the use of a temporary register.
>
> This patch introduces no new failures in test_verifier or test_bpf.c.
>
> Fixes: c5eae692571d6 ("ARM: net: bpf: improve 64-bit store implementation")
> Fixes: ec19e02b343db ("ARM: net: bpf: fix LDX instructions")
> Co-developed-by: Xi Wang <xi.wang@...il.com>
> Signed-off-by: Xi Wang <xi.wang@...il.com>
> Signed-off-by: Luke Nelson <luke.r.nels@...il.com>
Applied, thanks!
Powered by blists - more mailing lists