[PATCH v3] irqchip/gic: Fix UBSAN shift-out-of-bounds in GIC helpers

Zenghui Yu zenghui.yu at linux.dev
Wed Sep 23 02:20:10 PDT 2026


On 9/23/26 4:28 PM, Zhu Ling wrote:
> When running with UBSAN enabled, enabling a GPIO controller that uses a
> GIC interrupt as its parent triggers several shift-out-of-bounds warnings:
> 
>   shift-out-of-bounds in drivers/irqchip/irq-gic-common.c:50:21
>   left shift of 2 by 30 places cannot be represented in type 'int'
> 
> Similar reports are emitted from gic_poke_irq() and gic_peek_irq() in
> drivers/irqchip/irq-gic-v3.c. The corresponding GICv2 helpers use the
> same signed-shift pattern. These masks are generated by shifting signed
> integer constants, which invokes undefined behavior when bit 31 is
> selected.
> 
> Use BIT() to generate the masks with an unsigned type and make their
> intent explicit.
> 
> Signed-off-by: Zhu Ling <zhuling2709 at phytium.com.cn>
> ---
> Changes in v3:
> - Fix the same issue in the GICv2 gic_poke_irq() and gic_peek_irq()
>   helpers, as pointed out by Zenghui.
> 
> Changes in v2:
> - Use BIT() instead of explicit unsigned shifts, as suggested by Marc.
> - Drop the redundant introductory text from the email.
> - Update the author email address.
> 
> Link: https://lore.kernel.org/r/2fJDwUUYdEf2_eaRa041L9xkT8RkSWFeo7euOnqMbbPhUatLlEaAvGfB6sOspDmXaxO87Eh7bQLV9UolyjbMtZBT1wB2UGypjPOo0Z-RC0Q=@proton.me
> ---
>  drivers/irqchip/irq-gic-common.c | 2 +-
>  drivers/irqchip/irq-gic-v3.c     | 4 ++--
>  drivers/irqchip/irq-gic.c        | 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)

Looks good,

Reviewed-by: Zenghui Yu (Huawei) <zenghui.yu at linux.dev>

Thanks,
Zenghui



More information about the linux-arm-kernel mailing list