From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFA77234964 for ; Thu, 20 Aug 2026 08:17:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787213854; cv=none; b=tMtKu9PSkNw16RNa21fmdjHJ3JFPHA12nFSR8ci8FBXfRACaXxNKzam/f5vH4rFfsQC0Nz6Axspj8MhPNFHwsiSZOESEJXak1zQaDKyc3NypX7OP0luIkbUL2zP+Mnt3PbkPx4pMTyGn2tVcWeVbjTg+Ruct1t7V/xc4pJNJKKI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787213854; c=relaxed/simple; bh=RSUBy+dj73DXtkhU0Y9WVrrQwwRGX6LDTGT6tTccX/o=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=fR8zW8Ec89Ye9C1p2CT9wew1Vipcm+7iQP8srE7OgrwoFMpNujoaxFeaUfs1u2Ajh4b8UBDwc1cqbRUauhNXOQ48p3sI1tRr+BEtaNlCLLpIMayEmrp4tNSqRT6GJ94aqteQMUJEGfuzk9RFL7v6cUQb70WUb2yXkPHiRUkAu30= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DphvUniH; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DphvUniH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B3DE1F000E9; Thu, 20 Aug 2026 08:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787213851; bh=ShsBHu3y3fePWA2u7sofKwbce4P7U45++sbZsX5t9Os=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=DphvUniHM+kBXocq1JZUcDlHXY71gHyjzznfhDx0zOCa4QXggscVofPdWRp0t0yvd dcl7zNH3MizS1zeblwsCa3JB8QYGIiiwQHJIBYg1b8J3W8cdH3G/2BNsOQZ6m4KJBX zzVB3Mk9/wozGsxH3HmW5f/NyGaGiYl7QtDGH3DY8fV3jFIBmBx3qcMhoFGXWbww7P QKRKgeEuVX8zHm5/YM3GMYFL9QZKJL2QVe3wrlqJKvy4yXioQoorq+N8pOr3x7iwIS TWsrwZT7HEqilA8hN0Ph2ywY/P9RbpQYrDTa1sciMtmODaiD+fkj6LvuaCiMwhn5Qk nNUan1jnAwVTA== From: Thomas Gleixner To: Pengpeng Hou , Mark-PK Tsai Cc: Daniel Palmer , Matthias Brugger , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Pengpeng Hou Subject: Re: [PATCH] irqchip/mst-intc: reject ranges beyond saved state capacity In-Reply-To: <20260722041443.10020-1-pengpeng@iscas.ac.cn> References: <20260722041443.10020-1-pengpeng@iscas.ac.cn> Date: Thu, 20 Aug 2026 10:17:28 +0200 Message-ID: <87qzjti4tj.ffs@fw13> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Wed, Jul 22 2026 at 12:14, Pengpeng Hou wrote: > The inclusive Device Tree IRQ range determines nr_irqs. Suspend and > resume then use nr_irqs to walk the fixed saved_status array, which has > MST_INTC_MAX_IRQS entries. A descending range underflows the unsigned > subtraction, while a range wider than 64 entries exceeds that array. TBH, this is confusing at best. The problem is not the suspend/resume implication. The problem is that there is no validation of start/end to begin with. Whether that causes an out of bounds access somewhere down the road is immaterial. > Reject both forms before deriving nr_irqs. Both forms of what? Something like this: The interrupt range for the driver is retrieved from the device tree, but lacks any form of validation. As a consequence a malformed device tree can result in out of bound accesses when the range exceeds MST_INTC_MAX_IRQS. Add the missing sanity checks. > Signed-off-by: Pengpeng Hou Lacks a "Fixes:" tag. > --- > drivers/irqchip/irq-mst-intc.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/irqchip/irq-mst-intc.c b/drivers/irqchip/irq-mst-intc.c > index b5335f6fd6d6..1475335d668d 100644 > --- a/drivers/irqchip/irq-mst-intc.c > +++ b/drivers/irqchip/irq-mst-intc.c > @@ -263,6 +263,10 @@ static int __init mst_intc_of_init(struct device_node *dn, > of_property_read_u32_index(dn, "mstar,irqs-map-range", 1, &irq_end)) > return -EINVAL; > > + if (irq_end < irq_start || > + irq_end - irq_start >= MST_INTC_MAX_IRQS) No line break required. > + return -EINVAL; > + > cd = kzalloc_obj(*cd); > if (!cd) > return -ENOMEM;