* [PATCH] irqchip/xilinx: fix shift out of bounds warning
@ 2024-08-08 7:24 Radhey Shyam Pandey
2024-08-08 14:57 ` Thomas Gleixner
0 siblings, 1 reply; 2+ messages in thread
From: Radhey Shyam Pandey @ 2024-08-08 7:24 UTC (permalink / raw)
To: tglx, michal.simek
Cc: linux-kernel, linux-arm-kernel, git, Radhey Shyam Pandey
In case num_irq is 32 there is shift out of bound and result in false
warning "irq-xilinx: mismatch in kind-of-intr param" . To fix it cast
intr_mask to u64. It also fixes below shift out of bound warning
reported by UBSAN.
UBSAN: shift-out-of-bounds in irq-xilinx-intc.c:332:22
shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: d50466c90724 ("microblaze: intc: Refactor DT sanity check")
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
---
drivers/irqchip/irq-xilinx-intc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
index 238d3d344949..7e08714d507f 100644
--- a/drivers/irqchip/irq-xilinx-intc.c
+++ b/drivers/irqchip/irq-xilinx-intc.c
@@ -189,7 +189,7 @@ static int __init xilinx_intc_of_init(struct device_node *intc,
irqc->intr_mask = 0;
}
- if (irqc->intr_mask >> irqc->nr_irq)
+ if ((u64)irqc->intr_mask >> irqc->nr_irq)
pr_warn("irq-xilinx: mismatch in kind-of-intr param\n");
pr_info("irq-xilinx: %pOF: num_irq=%d, edge=0x%x\n",
base-commit: 6a0e38264012809afa24113ee2162dc07f4ed22b
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] irqchip/xilinx: fix shift out of bounds warning
2024-08-08 7:24 [PATCH] irqchip/xilinx: fix shift out of bounds warning Radhey Shyam Pandey
@ 2024-08-08 14:57 ` Thomas Gleixner
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2024-08-08 14:57 UTC (permalink / raw)
To: Radhey Shyam Pandey, michal.simek
Cc: linux-kernel, linux-arm-kernel, git, Radhey Shyam Pandey
On Thu, Aug 08 2024 at 12:54, Radhey Shyam Pandey wrote:
irqchip/xilinx: fix shift out of bounds warning
Please start the sentence after the colon with an upper case letter.
Also you can't fix a out of bound warning. You can fix the code which
causes the warning
> In case num_irq is 32 there is shift out of bound and result in false
What is num_irq? This is text and not subject to random acronyms.
https://www.kernel.org/doc/html/latest/process/maintainer-tip.html
> warning "irq-xilinx: mismatch in kind-of-intr param" . To fix it cast
> intr_mask to u64. It also fixes below shift out of bound warning
> reported by UBSAN.
>
> UBSAN: shift-out-of-bounds in irq-xilinx-intc.c:332:22
> shift exponent 32 is too large for 32-bit type 'unsigned int'
Something like this:
irqchip/xilinx: Fix shift out of bounds
The device tree property 'xlnx,kind-of-intr' is sanity checked that
the bitmask contains only set bits which are in the range of the
number of interrupts supported by the controller.
The check is done by shifting the mask right by the number of
supported interrupts and checking the result for zero.
The data type of the mask is u32 and the number of supported
interrupts is up to 32. In case of 32 interrupt the shift is out of
bounds, resulting in a mismatch warning. The out of bounds condition
was also caught by UBSAN.
Fix it by promoting the mask to u64 for the test.
Hmm?
Thanks,
tglx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-08 14:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-08 7:24 [PATCH] irqchip/xilinx: fix shift out of bounds warning Radhey Shyam Pandey
2024-08-08 14:57 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).