Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mehmet Fide" <mehmet.fide@gmail.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v4 1/3] pinctrl: imx: answer OUTPUT_ENABLE/INPUT_ENABLE queries from the pad register
Date: Thu, 03 Sep 2026 07:43:48 +0000	[thread overview]
Message-ID: <20260903074348.8F2DF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903073143.2068494-2-mehmet.fide@gmail.com>

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

Pre-existing issues:
- [Critical] Unvalidated `pin_id` derived from the device tree causes out-of-bounds access on `ipctl->pin_regs` and `info->pins`.
--

commit b6731ac627ae87e3857c262376df8e608a934f21
Author: Mehmet Fide <mehmet.fide@screeningeagle.com>

pinctrl: imx: answer OUTPUT_ENABLE/INPUT_ENABLE queries from the pad register

This patch updates the i.MX pinctrl driver to decode generic pinconfig
parameters for input and output enable. It answers these queries using the pad
register bits defined for specific SoCs. This allows chips like Vybrid to
report line directions correctly to gpio-mmio.

> diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
> index 9a45b376d36f9..f08ef52bf4f85 100644
> --- a/drivers/pinctrl/freescale/pinctrl-imx.c
> +++ b/drivers/pinctrl/freescale/pinctrl-imx.c

[ ... ]

> @@ -312,16 +313,61 @@ static int imx_pinconf_get_mmio(struct pinctrl_dev *pctldev, unsigned pin_id,
>  	return 0;
>  }
>  
> +static int imx_pinconf_get_mmio(struct pinctrl_dev *pctldev,
> +				unsigned int pin_id, unsigned long *config)
> +{
> +	struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
> +	const struct imx_pinctrl_soc_info *info = ipctl->info;
> +	const struct imx_pin_reg *pin_reg = &ipctl->pin_regs[pin_id];

[Severity: Critical]
This is a pre-existing issue, but can an unvalidated pin_id derived from the
device tree cause an out-of-bounds access on ipctl->pin_regs here?

During device probe, in drivers/pinctrl/freescale/pinctrl-imx.c in the
imx_pinctrl_parse_pin_mmio() function, the pin_id is computed directly from
register values in the fsl,pins property without bounding it to info->npins:

	*pin_id = (mux_reg != -1) ? mux_reg / 4 : conf_reg / 4;
	pin_reg = &ipctl->pin_regs[*pin_id];
	pin->pin = *pin_id;
	pin_reg->mux_reg = mux_reg;
	pin_reg->conf_reg = conf_reg;

If an improperly formatted or malicious device tree provides an excessively
large mux_reg or conf_reg, couldn't this lead to out-of-bounds memory
corruption, cascading into functions like imx_pinconf_get_mmio() which
implicitly assume pin_id is within bounds?

> +	enum pin_config_param param = pinconf_to_config_param(*config);
> +	unsigned int mask;
> +	u32 raw;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903073143.2068494-1-mehmet.fide@gmail.com?part=1

  reply	other threads:[~2026-09-03  7:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  7:31 [PATCH v4 0/3] gpio: mmio: report the line direction on chips without direction registers Mehmet Fide
2026-09-03  7:31 ` [PATCH v4 1/3] pinctrl: imx: answer OUTPUT_ENABLE/INPUT_ENABLE queries from the pad register Mehmet Fide
2026-09-03  7:43   ` sashiko-bot [this message]
2026-09-03  7:59     ` Mehmet Fide
2026-09-03  7:31 ` [PATCH v4 2/3] gpiolib: add get_config() and gpiochip_generic_get_config() Mehmet Fide
2026-09-03  7:45   ` sashiko-bot
2026-09-03  7:59     ` Mehmet Fide
2026-09-03  7:31 ` [PATCH v4 3/3] gpio: mmio: track the direction of chips without direction registers Mehmet Fide
2026-09-03  7:50   ` sashiko-bot
2026-09-03  7:59     ` Mehmet Fide

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=20260903074348.8F2DF1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=mehmet.fide@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox