From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Chen-Yu Tsai <wens@csie.org>,
Samuel Holland <samuel@sholland.org>
Cc: linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev,
Samuel Holland <samuel@sholland.org>
Subject: Re: [PATCH 1/2] rtc: sun6i: Prevent an out-of-bounds read
Date: Thu, 05 Jan 2023 18:26:02 +0100 [thread overview]
Message-ID: <8201852.NyiUUSuA9g@jernej-laptop> (raw)
In-Reply-To: <20221229184011.62925-1-samuel@sholland.org>
Dne četrtek, 29. december 2022 ob 19:40:10 CET je Samuel Holland napisal(a):
> If there is more than one parent clock in the devicetree, the
> driver sets .num_parents to a larger value than the number of array
> elements, which causes an out-of-bounds read in the clock framework.
Is there any DT with more than one parent? I think more fixes are needed if
this is the case.
Best regards,
Jernej
>
> Fix this by coercing the parent count to a Boolean value, like the
> driver expects.
>
> Fixes: 3855c2c3e546 ("rtc: sun6i: Expose the 32kHz oscillator")
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>
> drivers/rtc/rtc-sun6i.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
> index ed5516089e9a..a22358a44e32 100644
> --- a/drivers/rtc/rtc-sun6i.c
> +++ b/drivers/rtc/rtc-sun6i.c
> @@ -294,7 +294,7 @@ static void __init sun6i_rtc_clk_init(struct device_node
> *node,
>
> init.parent_names = parents;
> /* ... number of clock parents will be 1. */
> - init.num_parents = of_clk_get_parent_count(node) + 1;
> + init.num_parents = !!of_clk_get_parent_count(node) + 1;
> of_property_read_string_index(node, "clock-output-names", 0,
> &init.name);
WARNING: multiple messages have this Message-ID (diff)
From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Chen-Yu Tsai <wens@csie.org>,
Samuel Holland <samuel@sholland.org>
Cc: linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev,
Samuel Holland <samuel@sholland.org>
Subject: Re: [PATCH 1/2] rtc: sun6i: Prevent an out-of-bounds read
Date: Thu, 05 Jan 2023 18:26:02 +0100 [thread overview]
Message-ID: <8201852.NyiUUSuA9g@jernej-laptop> (raw)
In-Reply-To: <20221229184011.62925-1-samuel@sholland.org>
Dne četrtek, 29. december 2022 ob 19:40:10 CET je Samuel Holland napisal(a):
> If there is more than one parent clock in the devicetree, the
> driver sets .num_parents to a larger value than the number of array
> elements, which causes an out-of-bounds read in the clock framework.
Is there any DT with more than one parent? I think more fixes are needed if
this is the case.
Best regards,
Jernej
>
> Fix this by coercing the parent count to a Boolean value, like the
> driver expects.
>
> Fixes: 3855c2c3e546 ("rtc: sun6i: Expose the 32kHz oscillator")
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>
> drivers/rtc/rtc-sun6i.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
> index ed5516089e9a..a22358a44e32 100644
> --- a/drivers/rtc/rtc-sun6i.c
> +++ b/drivers/rtc/rtc-sun6i.c
> @@ -294,7 +294,7 @@ static void __init sun6i_rtc_clk_init(struct device_node
> *node,
>
> init.parent_names = parents;
> /* ... number of clock parents will be 1. */
> - init.num_parents = of_clk_get_parent_count(node) + 1;
> + init.num_parents = !!of_clk_get_parent_count(node) + 1;
> of_property_read_string_index(node, "clock-output-names", 0,
> &init.name);
_______________________________________________
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:[~2023-01-05 17:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-29 18:40 [PATCH 1/2] rtc: sun6i: Prevent an out-of-bounds read Samuel Holland
2022-12-29 18:40 ` Samuel Holland
2022-12-29 18:40 ` [PATCH 2/2] rtc: sun6i: Drop the unused has_out_clk flag Samuel Holland
2022-12-29 18:40 ` Samuel Holland
2023-01-05 17:18 ` Jernej Škrabec
2023-01-05 17:18 ` Jernej Škrabec
2023-01-05 17:26 ` Jernej Škrabec [this message]
2023-01-05 17:26 ` [PATCH 1/2] rtc: sun6i: Prevent an out-of-bounds read Jernej Škrabec
2023-01-07 17:15 ` Samuel Holland
2023-01-07 17:15 ` Samuel Holland
2023-01-08 19:39 ` Jernej Škrabec
2023-01-08 19:39 ` Jernej Škrabec
2023-02-12 21:10 ` Samuel Holland
2023-02-12 21:10 ` Samuel Holland
2023-02-09 22:49 ` Alexandre Belloni
2023-02-09 22:49 ` Alexandre Belloni
2023-02-12 21:11 ` Samuel Holland
2023-02-12 21:11 ` Samuel Holland
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=8201852.NyiUUSuA9g@jernej-laptop \
--to=jernej.skrabec@gmail.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=samuel@sholland.org \
--cc=wens@csie.org \
/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.