From: Greg KH <gregkh@linuxfoundation.org>
To: Zhou Qingyang <zhou1615@umn.edu>
Cc: kjlu@umn.edu, Abel Vesa <abel.vesa@nxp.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
Adam Ford <aford173@gmail.com>,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: imx: Fix a NULL pointer dereference in imx_register_uart_clocks()
Date: Fri, 28 Jan 2022 11:16:20 +0100 [thread overview]
Message-ID: <YfPCdPuoB3RYgzL8@kroah.com> (raw)
In-Reply-To: <20220124165206.55059-1-zhou1615@umn.edu>
On Tue, Jan 25, 2022 at 12:52:06AM +0800, Zhou Qingyang wrote:
> In imx_register_uart_clocks(), the global variable imx_uart_clocks is
> assigned by kcalloc() and there is a dereference of in the next for loop,
> which could introduce a NULL pointer dereference on failure of kcalloc().
>
> Fix this by adding a NULL check of imx_uart_clocks.
>
> This bug was found by a static analyzer.
>
> Builds with 'make allyesconfig' show no new warnings,
> and our static analyzer no longer warns about this code.
>
> Fixes: 379c9a24cc23 ("clk: imx: Fix reparenting of UARTs not associated with stdout")
> Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
> ---
> The analysis employs differential checking to identify inconsistent
> security operations (e.g., checks or kfrees) between two code paths
> and confirms that the inconsistent operations are not recovered in the
> current function or the callers, so they constitute bugs.
>
> Note that, as a bug found by static analysis, it can be a false
> positive or hard to trigger. Multiple researchers have cross-reviewed
> the bug.
>
> drivers/clk/imx/clk.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
> index 7cc669934253..99249ab361d2 100644
> --- a/drivers/clk/imx/clk.c
> +++ b/drivers/clk/imx/clk.c
> @@ -173,6 +173,8 @@ void imx_register_uart_clocks(unsigned int clk_count)
> int i;
>
> imx_uart_clocks = kcalloc(clk_count, sizeof(struct clk *), GFP_KERNEL);
> + if (!imx_uart_clocks)
> + return;
>
> if (!of_stdout)
> return;
> --
> 2.25.1
>
As stated before, umn.edu is still not allowed to contribute to the
Linux kernel. Please work with your administration to resolve this
issue.
WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Zhou Qingyang <zhou1615@umn.edu>
Cc: kjlu@umn.edu, Abel Vesa <abel.vesa@nxp.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
Adam Ford <aford173@gmail.com>,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: imx: Fix a NULL pointer dereference in imx_register_uart_clocks()
Date: Fri, 28 Jan 2022 11:16:20 +0100 [thread overview]
Message-ID: <YfPCdPuoB3RYgzL8@kroah.com> (raw)
In-Reply-To: <20220124165206.55059-1-zhou1615@umn.edu>
On Tue, Jan 25, 2022 at 12:52:06AM +0800, Zhou Qingyang wrote:
> In imx_register_uart_clocks(), the global variable imx_uart_clocks is
> assigned by kcalloc() and there is a dereference of in the next for loop,
> which could introduce a NULL pointer dereference on failure of kcalloc().
>
> Fix this by adding a NULL check of imx_uart_clocks.
>
> This bug was found by a static analyzer.
>
> Builds with 'make allyesconfig' show no new warnings,
> and our static analyzer no longer warns about this code.
>
> Fixes: 379c9a24cc23 ("clk: imx: Fix reparenting of UARTs not associated with stdout")
> Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
> ---
> The analysis employs differential checking to identify inconsistent
> security operations (e.g., checks or kfrees) between two code paths
> and confirms that the inconsistent operations are not recovered in the
> current function or the callers, so they constitute bugs.
>
> Note that, as a bug found by static analysis, it can be a false
> positive or hard to trigger. Multiple researchers have cross-reviewed
> the bug.
>
> drivers/clk/imx/clk.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
> index 7cc669934253..99249ab361d2 100644
> --- a/drivers/clk/imx/clk.c
> +++ b/drivers/clk/imx/clk.c
> @@ -173,6 +173,8 @@ void imx_register_uart_clocks(unsigned int clk_count)
> int i;
>
> imx_uart_clocks = kcalloc(clk_count, sizeof(struct clk *), GFP_KERNEL);
> + if (!imx_uart_clocks)
> + return;
>
> if (!of_stdout)
> return;
> --
> 2.25.1
>
As stated before, umn.edu is still not allowed to contribute to the
Linux kernel. Please work with your administration to resolve this
issue.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-01-28 10:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 16:52 [PATCH] clk: imx: Fix a NULL pointer dereference in imx_register_uart_clocks() Zhou Qingyang
2022-01-24 16:52 ` Zhou Qingyang
2022-01-28 10:16 ` Greg KH [this message]
2022-01-28 10:16 ` Greg KH
2022-01-28 13:47 ` Adam Ford
2022-01-28 13:47 ` Adam Ford
2022-01-28 15:50 ` Greg KH
2022-01-28 15:50 ` Greg KH
2022-01-28 21:21 ` Abel Vesa
2022-01-28 21:21 ` Abel Vesa
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=YfPCdPuoB3RYgzL8@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=abel.vesa@nxp.com \
--cc=aford173@gmail.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=kjlu@umn.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.org \
--cc=zhou1615@umn.edu \
/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.