All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sneh Mankad" <sneh.mankad@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH 3/7] irqchip/irq-qcom-mpm: Prepare common access path for timer and pin regs
Date: Mon, 13 Jul 2026 10:39:24 +0000	[thread overview]
Message-ID: <20260713103925.557CE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713-b4-shikra_lpm_addition-v1-3-3d858df2cbbf@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] The initialization loop in the probe function writes zeroes to registers based on the device tree property `qcom,mpm-pin-count` without verifying if the calculated `reg_stride` fits within the mapped I/O memory region.
- [High] Lack of bounds checking on `d->hwirq` combined with signed integer conversion allows arbitrary out-of-bounds memory accesses when reading/writing IRQ registers.
--

--- Patch [3]: [PATCH 3/7] irqchip/irq-qcom-mpm: Prepare common access path for timer and pin regs ---
commit 481c7b7ccc27a48778456542a65ce5c589dcaa00
Author: Sneh Mankad <sneh.mankad@oss.qualcomm.com>

irqchip/irq-qcom-mpm: Prepare common access path for timer and pin regs

This commit introduces a common addressing helper, qcom_mpm_offset(),
to calculate memory offsets for both timer and pin registers. It also 
replaces the macro definitions for vMPM registers with an enum and 
updates the read/write accessor functions to use it.

> diff --git a/drivers/irqchip/irq-qcom-mpm.c b/drivers/irqchip/irq-qcom-mpm.c
> index 01fd1843172aa..763eddee99dc4 100644
> --- a/drivers/irqchip/irq-qcom-mpm.c
> +++ b/drivers/irqchip/irq-qcom-mpm.c
[ ... ]
> @@ -92,18 +97,36 @@ struct qcom_mpm_priv {
>  	atomic_t cpus_in_pm;
>  };
>  
> -static u32 qcom_mpm_read(struct qcom_mpm_priv *priv, unsigned int reg,
> -			 unsigned int index)
> +static unsigned int qcom_mpm_offset(struct qcom_mpm_priv *priv, enum qcom_mpm_reg reg,
> +				    unsigned int index)
> +{
> +	unsigned int reg_offset;
> +
> +	/*
> +	 * Per the vMPM register map, TIMER[0..1] starts at register index 0 and all pin-specific
> +	 * registers start after the two TIMER regs. Pin-specific register IDs start at
> +	 * MPM_REG_ENABLE, so subtract it to convert to a zero-based pin-register group index.
> +	 */
> +	if (reg == MPM_REG_TIMER)
> +		reg_offset = index;
> +	else
> +		reg_offset = MPM_TIMER_REGS +
> +			 (reg - MPM_REG_ENABLE) * priv->reg_stride + index;
> +
> +	return reg_offset * sizeof(u32);
> +}

[Severity: High]
This isn't a bug introduced by this patch, but I'm wondering if
priv->reg_stride is validated against the size of the mapped I/O memory region?

Looking at qcom_mpm_probe():

	priv->reg_stride = DIV_ROUND_UP(pin_cnt, 32);

If a very large qcom,mpm-pin-count is provided in the device tree, could the
initialization loop later in qcom_mpm_probe():

	for (i = 0; i < priv->reg_stride; i++) {
		qcom_mpm_write(priv, MPM_REG_ENABLE, i, 0);
		...

write zeroes out of bounds into memory following priv->base?

[Severity: High]
This is a pre-existing issue, but does this function safely handle the index
parameter against malformed device tree inputs?

In qcom_mpm_alloc(), pin is assigned as d->hwirq from the device tree
interrupt specifier without bounds validation against domain->hwirq_max.

Later in qcom_mpm_enable_irq():

	int pin = d->hwirq;
	unsigned int index = pin / 32;

If a sufficiently large d->hwirq (e.g., 0x80000000) is provided, would the
signed integer conversion cause it to wrap into a negative number, resulting
in a massive unsigned index being passed into qcom_mpm_offset() and allowing
arbitrary out-of-bounds memory accesses?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260713-b4-shikra_lpm_addition-v1-0-3d858df2cbbf@oss.qualcomm.com?part=3

  reply	other threads:[~2026-07-13 10:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 10:25 [PATCH 0/7] Register MPM under CPU cluster power domain to manage RPM notification Sneh Mankad
2026-07-13 10:25 ` [PATCH 1/7] dt-bindings: interrupt-controller: mpm: Document power-domains property Sneh Mankad
2026-07-13 10:36   ` sashiko-bot
2026-07-13 11:26   ` Konrad Dybcio
2026-07-13 15:11   ` Marc Zyngier
2026-07-13 10:25 ` [PATCH 2/7] irqchip/irq-qcom-mpm: Register MPM under CPU cluster power domain Sneh Mankad
2026-07-13 10:41   ` sashiko-bot
2026-07-13 10:25 ` [PATCH 3/7] irqchip/irq-qcom-mpm: Prepare common access path for timer and pin regs Sneh Mankad
2026-07-13 10:39   ` sashiko-bot [this message]
2026-07-13 10:25 ` [PATCH 4/7] irqchip/irq-qcom-mpm: Program wakeup timer when CPU cluster goes to LPM Sneh Mankad
2026-07-13 10:38   ` sashiko-bot
2026-07-13 15:18   ` Marc Zyngier
2026-07-13 10:25 ` [PATCH 5/7] arm64: dts: qcom: sm6375: Make MPM device as part of CPU cluster domain Sneh Mankad
2026-07-13 10:40   ` sashiko-bot
2026-07-13 10:25 ` [PATCH 6/7] arm64: dts: qcom: agatti: Do not mark MPM as power domain Sneh Mankad
2026-07-13 10:39   ` sashiko-bot
2026-07-13 10:25 ` [PATCH 7/7] arm64: dts: qcom: shikra: Add CPU idle states Sneh Mankad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260713103925.557CE1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sneh.mankad@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.