[PATCH v3 2/6] bpf: fix signed shift overflows in ARM JIT
Konstantin Ananyev
konstantin.ananyev at huawei.com
Fri Dec 19 14:13:29 CET 2025
>
> 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'
>
> To fix the issue use RTE_BIT32 and similar macros instead.
>
> Signed-off-by: Marat Khalili <marat.khalili at huawei.com>
> Acked-by: Morten Brørup <mb at smartsharesystems.com>
> ---
Acked-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
> --
> 2.43.0
More information about the stable
mailing list