linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v4][PATCH] pinctrl: freescale: Fix a memory out of bounds when num_configs is 1
@ 2023-05-04 23:37 Xiaolei Wang
  2023-05-05  0:53 ` Peng Fan
  2023-06-16 13:00 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Xiaolei Wang @ 2023-05-04 23:37 UTC (permalink / raw)
  To: aisheng.dong, festevam, shawnguo, ping.bai, kernel,
	linus.walleij, peng.fan, shenwei.wang, bartosz.golaszewski
  Cc: linux-gpio, linux-kernel

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")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
---
Changes since  v3:
 - update commit log, delete call trace

 drivers/pinctrl/freescale/pinctrl-scu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/freescale/pinctrl-scu.c b/drivers/pinctrl/freescale/pinctrl-scu.c
index ea261b6e7458..3b252d684d72 100644
--- a/drivers/pinctrl/freescale/pinctrl-scu.c
+++ b/drivers/pinctrl/freescale/pinctrl-scu.c
@@ -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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [v4][PATCH] pinctrl: freescale: Fix a memory out of bounds when num_configs is 1
  2023-05-04 23:37 [v4][PATCH] pinctrl: freescale: Fix a memory out of bounds when num_configs is 1 Xiaolei Wang
@ 2023-05-05  0:53 ` Peng Fan
  2023-06-14  2:59   ` wangxiaolei
  2023-06-16 13:00 ` Linus Walleij
  1 sibling, 1 reply; 4+ messages in thread
From: Peng Fan @ 2023-05-05  0:53 UTC (permalink / raw)
  To: Xiaolei Wang, Aisheng Dong, festevam, shawnguo, Jacky Bai,
	kernel, linus.walleij, Shenwei Wang, bartosz.golaszewski
  Cc: linux-gpio, linux-kernel

> 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")
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [v4][PATCH] pinctrl: freescale: Fix a memory out of bounds when num_configs is 1
  2023-05-05  0:53 ` Peng Fan
@ 2023-06-14  2:59   ` wangxiaolei
  0 siblings, 0 replies; 4+ messages in thread
From: wangxiaolei @ 2023-06-14  2:59 UTC (permalink / raw)
  To: Peng Fan, Aisheng Dong, festevam, shawnguo, Jacky Bai, kernel,
	linus.walleij, Shenwei Wang, bartosz.golaszewski
  Cc: linux-gpio, linux-kernel


On 5/5/23 8:53 AM, Peng Fan wrote:
> 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.
>
>> 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")
>> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>

Can someone help merge this patch?

thanks

xiaolei


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [v4][PATCH] pinctrl: freescale: Fix a memory out of bounds when num_configs is 1
  2023-05-04 23:37 [v4][PATCH] pinctrl: freescale: Fix a memory out of bounds when num_configs is 1 Xiaolei Wang
  2023-05-05  0:53 ` Peng Fan
@ 2023-06-16 13:00 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2023-06-16 13:00 UTC (permalink / raw)
  To: Xiaolei Wang
  Cc: aisheng.dong, festevam, shawnguo, ping.bai, kernel, peng.fan,
	shenwei.wang, bartosz.golaszewski, linux-gpio, linux-kernel

On Fri, May 5, 2023 at 1:38 AM Xiaolei Wang <xiaolei.wang@windriver.com> wrote:

> 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")
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
> ---
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-16 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04 23:37 [v4][PATCH] pinctrl: freescale: Fix a memory out of bounds when num_configs is 1 Xiaolei Wang
2023-05-05  0:53 ` Peng Fan
2023-06-14  2:59   ` wangxiaolei
2023-06-16 13:00 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).