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

From: Marc Zyngier

Date: Thu Sep 24 2026 - 14:21:22 EST


On Wed, 23 Sep 2026 09:28:04 +0100,
Zhu Ling <zhuling2709@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxx>

Acked-by: Marc Zyngier <maz@xxxxxxxxxx>

M.

--
Without deviation from the norm, progress is not possible.