Skip to contentSkip to conversation

pinctrl: freescale: Fix a memory out of bounds when num_configs is 1

PATCH In review Xiaolei Wang 3 participants 4 messages May 4, 2023 – Jun 16, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 pinctrl: freescale: Fix a memory out of bounds when num_configs is 1

The config passed in by pad wakeup is 1, when num_configs is 1, Configuration [1] should not be fetched, which will be detected by KASAN as a memory out of bounds condition. Modify to get configs[1] when num_configs is 2.

Fixes f60c9eac54af ("gpio: mxc: enable pad wakeup on i.MX8x platforms")

---
Changes since v3:
- update commit log, delete call trace

 drivers/pinctrl/freescale/pinctrl-scu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pinctrl/freescale/pinctrl-scu.c +2 -1
index ea261b6e7458..3b252d684d72 100644
@@ -90,7 +90,7 @@ int imx_pinconf_set_scu(struct pinctrl_dev *pctldev, unsigned pin_id,
 	struct imx_sc_msg_req_pad_set msg;
 	struct imx_sc_rpc_msg *hdr = &msg.hdr;
 	unsigned int mux = configs[0];
-	unsigned int conf = configs[1];
+	unsigned int conf;
 	unsigned int val;
 	int ret;
 
@@ -115,6 +115,7 @@ int imx_pinconf_set_scu(struct pinctrl_dev *pctldev, unsigned pin_id,
 	 * Set mux and conf together in one IPC call
 	 */
 	WARN_ON(num_configs != 2);
+	conf = configs[1];
 
 	val = conf | BM_PAD_CTL_IFMUX_ENABLE | BM_PAD_CTL_GP_ENABLE;
 	val |= mux << BP_PAD_CTL_IFMUX;
Signature · 1 line
2.25.1
Reviewed-by on v4 1/1
#1 lore raw
Quoted 10 lines

Subject: [v4][PATCH] pinctrl: freescale: Fix a memory out of bounds when num_configs is 1

The config passed in by pad wakeup is 1, when num_configs is 1, Configuration [1] should not be fetched, which will be detected by KASAN as a memory out of bounds condition. Modify to get configs[1] when num_configs is 2.

Fixes f60c9eac54af ("gpio: mxc: enable pad wakeup on i.MX8x platforms")
#2 lore raw
Quoted 6 lines · Peng Fan

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 3 lines

Subject: [v4][PATCH] pinctrl: freescale: Fix a memory out of bounds when num_configs is 1

Quoted 8 lines
Quoted 7 lines

The config passed in by pad wakeup is 1, when num_configs is 1, Configuration [1] should not be fetched, which will be detected by KASAN as a memory out of bounds condition. Modify to get configs[1] when num_configs is 2.

Fixes f60c9eac54af ("gpio: mxc: enable pad wakeup on i.MX8x platforms")

Can someone help merge this patch?

thanks

xiaolei

#3 lore raw
In reply to Xiaolei Wang
Quoted 10 lines · Xiaolei Wang

The config passed in by pad wakeup is 1, when num_configs is 1, Configuration [1] should not be fetched, which will be detected by KASAN as a memory out of bounds condition. Modify to get configs[1] when num_configs is 2.

Fixes f60c9eac54af ("gpio: mxc: enable pad wakeup on i.MX8x platforms")

---
Changes since v3:
- update commit log, delete call trace

Patch applied.

Right now I have applied it for the merge window for kernel v6.5, tell me if it is really urgent and should rather go in for fixes.

Yours,
Linus Walleij