[PATCH 1/3] bpf: fix signed shift overflows in ARM JIT
Jerin Jacob
jerinjacobk at gmail.com
Wed Nov 12 06:23:57 CET 2025
On Tue, Nov 11, 2025 at 10:09 PM Marat Khalili <marat.khalili at huawei.com> wrote:
>
> > -----Original Message-----
> > From: Jerin Jacob <jerinjacobk at gmail.com>
> > Sent: Tuesday 11 November 2025 16:31
> > To: Marat Khalili <marat.khalili at huawei.com>
> > Cc: Konstantin Ananyev <konstantin.ananyev at huawei.com>; Stephen Hemminger <stephen at networkplumber.org>;
> > dev at dpdk.org
> > Subject: Re: [PATCH 1/3] bpf: fix signed shift overflows in ARM JIT
> >
> > On Tue, Nov 11, 2025 at 3:40 PM Marat Khalili <marat.khalili at huawei.com> wrote:
> > >
> > > > On Mon, Nov 10, 2025 at 9:01 PM Marat Khalili <marat.khalili at huawei.com> wrote:
> > > > >
> > > > > Left shifts of integer literals and bool values overwriting the sign bit
> > > > > were used multiple times in bpf_jit_arm64.c. E.g.:
> > > > >
> > > > > insn = (!!is64) << 31;
> > > > >
> > > > > where is64 has type bool (double bang is a no-op here). The operand of
> > > > > left shift was promoted to type int, which when 32-bit wide cannot
> > > > > represent the result. Similarly literal integers have int type by
> > > > > default. Sanitizer produced the following diagnostic during runtime
> > > > > (for various lines):
> > > > >
> > > > > lib/bpf/bpf_jit_arm64.c:241:18: runtime error: left shift of 1 by 31
> > > > > places cannot be represented in type 'int'
> > > >
> > > > Wonder why none of the tests in app/test/test_bpf.c able to catch
> > > > this? The generated ARM opcode looks OK (otherwise tests wont pass).
> > > > Could you check what is missing in the app/test/test_bpf.c?
> > >
> > > That tests do trigger it.
> > >
> > > RTE>>bpf_autotest
> > > ../../src/lib/bpf/bpf_jit_arm64.c:320:18: runtime error: left shift of 1 by 31 places cannot be
> > represented in type 'int'
> >
> > This is when ASAN is enabled. Right?
>
> More likely UBSAN, but yes.
>
> > Is it really generating BAD
> > opcode(i.e emiter generating bad OPcode) and test fails?
>
> If allowed to finish the test does not fail.
Does that mean, it is a false positive? Right?
Anyway, There is no harm in the new patch, Change the patch to use
SHIFT macros from EAL.
> However, I have not compared DPDK or JIT compiled code with and without changes.
More information about the dev
mailing list