[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7d680ad8-8851-dd4e-49f5-0d6054cf8de0@iogearbox.net>
Date: Wed, 10 Aug 2022 16:53:55 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: Jean-Philippe Brucker <jean-philippe@...aro.org>,
Xu Kuohai <xukuohai@...wei.com>
Cc: bpf@...r.kernel.org, linux-kernel@...r.kernel.org, lkp@...el.com,
kbuild-all@...ts.01.org, catalin.marinas@....com, will@...nel.org
Subject: Re: [PATCH bpf] bpf, arm64: Fix bpf trampoline instruction endianness
On 8/9/22 12:33 PM, Jean-Philippe Brucker wrote:
> [+ arm64 maintainers]
>
> On Mon, Aug 08, 2022 at 12:07:35AM -0400, Xu Kuohai wrote:
>> The sparse tool complains as follows:
>>
>> arch/arm64/net/bpf_jit_comp.c:1684:16:
>> warning: incorrect type in assignment (different base types)
>> arch/arm64/net/bpf_jit_comp.c:1684:16:
>> expected unsigned int [usertype] *branch
>> arch/arm64/net/bpf_jit_comp.c:1684:16:
>> got restricted __le32 [usertype] *
>> arch/arm64/net/bpf_jit_comp.c:1700:52:
>> error: subtraction of different types can't work (different base
>> types)
>> arch/arm64/net/bpf_jit_comp.c:1734:29:
>> warning: incorrect type in assignment (different base types)
>> arch/arm64/net/bpf_jit_comp.c:1734:29:
>> expected unsigned int [usertype] *
>> arch/arm64/net/bpf_jit_comp.c:1734:29:
>> got restricted __le32 [usertype] *
>> arch/arm64/net/bpf_jit_comp.c:1918:52:
>> error: subtraction of different types can't work (different base
>> types)
>>
>> This is because the variable branch in function invoke_bpf_prog and the
>> variable branches in function prepare_trampoline are defined as type
>> u32 *, which conflicts with ctx->image's type __le32 *, so sparse complains
>> when assignment or arithmetic operation are performed on these two
>> variables and ctx->image.
>>
>> Since arm64 instructions are always little-endian, change the type of
>> these two variables to __le32 * and call cpu_to_le32 to convert
>> instruction to little-endian before writing it to memory.
>>
>> Reported-by: kernel test robot <lkp@...el.com>
>> Fixes: efc9909fdce0 ("bpf, arm64: Add bpf trampoline for arm64")
>> Signed-off-by: Xu Kuohai <xukuohai@...wei.com>
>
> Reviewed-by: Jean-Philippe Brucker <jean-philippe@...aro.org>
Applied, thanks! Also added small note that this is in line with emit() as well.
Powered by blists - more mailing lists