From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Barry Song <baohua@kernel.org>,
Vineet Gupta <vgupta@synopsys.com>, Jiri Slaby <jslaby@suse.com>,
Michal Simek <michal.simek@xilinx.com>,
linux-serial@vger.kernel.org, linux-snps-arc@lists.infradead.org,
linux-renesas-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/9] serial: imx: Fix out-of-bounds access through DT alias
Date: Tue, 20 Feb 2018 11:31:34 +0100 [thread overview]
Message-ID: <20180220103134.xfh2zl2vgonb2ywb@pengutronix.de> (raw)
In-Reply-To: <1519119624-1268-4-git-send-email-geert+renesas@glider.be>
Hello Geert,
On Tue, Feb 20, 2018 at 10:40:18AM +0100, Geert Uytterhoeven wrote:
> The imx_ports[] array is indexed using a value derived from the
> "serialN" alias in DT, which may lead to an out-of-bounds access.
>
> Fix this by adding a range check.
>
> Fixes: 9206ab8a0350c3da ("serial: imx: Fix out-of-bounds access through DT alias")
huh, this patch fixes itself?
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> drivers/tty/serial/imx.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 1d7ca382bc12b238..e89e90ad87d8245c 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -2041,6 +2041,11 @@ static int serial_imx_probe(struct platform_device *pdev)
> serial_imx_probe_pdata(sport, pdev);
> else if (ret < 0)
> return ret;
I'd prefer an empty line here.
> + if (sport->port.line >= UART_NR) {
I would have used:
if (sport->port.line >= ARRAY_SIZE(imx_ports))
which IMHO is better understandable
> + dev_err(&pdev->dev, "serial%d out of range\n",
> + sport->port.line);
Note that the same overflow can happen when a device is probed using
platform data (and your commit fixes that, too). Maybe worth to point
out in the commit log?
Other than that: Good catch, thanks for your patch.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2018-02-20 10:32 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-20 9:40 [PATCH 0/9] serial: Fix out-of-bounds accesses through DT aliases Geert Uytterhoeven
2018-02-20 9:40 ` [PATCH 1/9] serial: arc_uart: Fix out-of-bounds access through DT alias Geert Uytterhoeven
2018-02-20 10:50 ` Geert Uytterhoeven
2018-02-20 9:40 ` [PATCH 2/9] serial: fsl_lpuart: " Geert Uytterhoeven
2018-02-20 10:51 ` Geert Uytterhoeven
2018-02-20 9:40 ` [PATCH 3/9] serial: imx: " Geert Uytterhoeven
2018-02-20 10:31 ` Uwe Kleine-König [this message]
2018-02-20 10:49 ` Geert Uytterhoeven
2018-02-20 9:40 ` [PATCH 4/9] serial: mxs-auart: " Geert Uytterhoeven
2018-02-20 10:51 ` Geert Uytterhoeven
2018-02-20 9:40 ` [PATCH 5/9] serial: pxa: " Geert Uytterhoeven
2018-02-20 10:52 ` Geert Uytterhoeven
2018-02-20 9:40 ` [PATCH 6/9] serial: samsung: " Geert Uytterhoeven
2018-02-20 10:52 ` Geert Uytterhoeven
2018-02-20 9:40 ` [PATCH 7/9] serial: sh-sci: " Geert Uytterhoeven
2018-02-20 10:53 ` Geert Uytterhoeven
2018-02-20 9:40 ` [PATCH 8/9] serial: sirf: " Geert Uytterhoeven
2018-02-20 10:53 ` Geert Uytterhoeven
2018-02-20 9:40 ` [PATCH 9/9] serial: xuartps: " Geert Uytterhoeven
2018-02-20 10:22 ` Michal Simek
2018-02-20 10:38 ` Geert Uytterhoeven
2018-02-20 11:27 ` Michal Simek
2018-02-20 12:27 ` Geert Uytterhoeven
2018-02-20 12:39 ` Michal Simek
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=20180220103134.xfh2zl2vgonb2ywb@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=baohua@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=michal.simek@xilinx.com \
--cc=vgupta@synopsys.com \
/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
all inboxes | Powered by JetHome®