linux/rust/kernel/pci
Sophon Zhang 8d7b3e41ff rust: pci: reject IRQ vector indices that do not fit in u32
IrqVectorRegistration::index() accepts a usize, but pci_irq_vector()
takes an unsigned int. On 64-bit architectures, casting an index larger
than u32::MAX wraps it before the PCI core can validate it. In
particular, u32::MAX + 1 becomes zero and can resolve to the first
allocated vector.

Use a checked conversion and return EINVAL when the index cannot be
represented by the C API.

Fixes: 2fb7755b0a ("rust: pci: resolve IRQ in index() and embed IrqRequest in IrqVector")
Signed-off-by: Sophon Zhang <aiqubits@hotmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260901-fix-pci-irq-vector-index-truncation-v4-1-f94aa6932fd9@hotmail.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-09-01 18:21:01 +02:00
..
id.rs rust: device: make Core and CoreInternal lifetime-parameterized 2026-05-27 16:22:42 +02:00
io.rs I/O type generalization and projection 2026-07-13 23:50:39 +02:00
irq.rs rust: pci: reject IRQ vector indices that do not fit in u32 2026-09-01 18:21:01 +02:00