From nobody Sat Jul 25 04:30:47 2026 Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A16F1FC8 for ; Sat, 18 Jul 2026 04:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784349430; cv=none; b=b9JM9gM8Tog5j1+OcOsWnuXUEErGs4rm/GDd0lSpUejqgBpe5jiS2WP6mi6OQZwTHCs1+q5rdDU2zy5HAcKTl3pG9QsYvgRuBiNtHPX+0XDWJqjwIbEhE4W9HfvXWvOo+aWc7Iv4LySZLJEntN28G16OxPmDHuZt+g8KylZ9wiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784349430; c=relaxed/simple; bh=AZKRKrxhWAsnxMV6369+YgG4/gEV2IErOydrdON7qaM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sxoVvUGJeFTD2Ee8BCzU4P//mN3AGzczUgBdSeCP6qArF0Q6vhAzJYAdCuDxtyui1BI8E/yNsNXc1PBXyDAGniXnaick0/K0carQ5/FfbyNqcEl8rBmQ9zgXVecK9pI53LvHgiGWx9tPIVxmhRxgPSdFntwcQrAtzrnrdaix7D8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from localhost.localdomain (unknown [111.196.245.140]) by APP-03 (Coremail) with SMTP id rQCowAAnM0HqAltqw04uAA--.37663S2; Sat, 18 Jul 2026 12:36:59 +0800 (CST) From: Pengpeng Hou To: Rahul Pathak Cc: Pengpeng Hou , Anup Patel , Thomas Gleixner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] irqchip/riscv-rpmi-sysmsi: Validate system MSI indices Date: Sat, 18 Jul 2026 12:36:58 +0800 Message-ID: <20260718040000.006.d6f39b01-caplitmus-rv@iscas.ac.cn> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: rQCowAAnM0HqAltqw04uAA--.37663S2 X-Coremail-Antispam: 1UD129KBjvJXoW7tr1rKF48ur1UKrW7Kw13XFb_yoW8Wr1UpF Wjga9I9r4rtF4jv3ya9w48W345C3WvkFWjgFWjywn7Xr13Kryvkr1xuFyYqry8AF43Gw48 CrZavayUu34UAFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9I14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r 4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2Wl Yx0E2Ix0cI8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbV WUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7Cj xVA2Y2ka0xkIwI1lc7CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4I kC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWU WwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr 0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWU JVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJb IYCTnIWIevJa73UjIFyTuYvjfUoWlkDUUUU X-CM-SenderInfo: pshqw1xhqjqxpvfd2hldfou0/ Content-Type: text/plain; charset="utf-8" SYS_NUM_MSI is the number of available system MSIs. OpenSBI and the Linux wired-MSI domain therefore treat valid system MSI indices as the half-open range [0, SYS_NUM_MSI). The driver stores this count in nr_irqs, but its translation callback only subtracts gsi_base. For DT, gsi_base is zero, so an interrupt specifier at or above SYS_NUM_MSI can be retained as the hardware interrupt number. The wired MSI allocation path uses a separate descriptor index and preserves the hardware number in the MSI cookie, so the domain size does not reject it. Reject a raw value below gsi_base and a translated value outside that half-open range. Fixes: aa43953e862c ("irqchip: Add driver for the RPMI system MSI service g= roup") Signed-off-by: Pengpeng Hou --- drivers/irqchip/irq-riscv-rpmi-sysmsi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-riscv-rpmi-sysmsi.c b/drivers/irqchip/irq-= riscv-rpmi-sysmsi.c index 612f3972f7af0..9d957f8a12477 100644 --- a/drivers/irqchip/irq-riscv-rpmi-sysmsi.c +++ b/drivers/irqchip/irq-riscv-rpmi-sysmsi.c @@ -174,8 +174,13 @@ static int rpmi_sysmsi_translate(struct irq_domain *d,= struct irq_fwspec *fwspec if (WARN_ON(fwspec->param_count < 1)) return -EINVAL; =20 - /* For DT, gsi_base is always zero. */ + if (fwspec->param[0] < priv->gsi_base) + return -EINVAL; + *hwirq =3D fwspec->param[0] - priv->gsi_base; + if (*hwirq >=3D priv->nr_irqs) + return -EINVAL; + *type =3D IRQ_TYPE_NONE; return 0; } --=20 2.43.0