From: Segher Boessenkool <segher@kernel.crashing.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: pmenzel@molgen.mpg.de, linux-kernel@vger.kernel.org,
Paul Mackerras <paulus@samba.org>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds
Date: Mon, 10 May 2021 16:14:44 -0500 [thread overview]
Message-ID: <20210510211444.GE10366@gate.crashing.org> (raw)
In-Reply-To: <d5e3c8e66bad3725d7d48d0e45c4b7eb7c02631d.1620455671.git.christophe.leroy@csgroup.eu>
On Sat, May 08, 2021 at 06:36:21AM +0000, Christophe Leroy wrote:
> UBSAN complains when a pointer is calculated with invalid
> 'legacy_serial_console' index, allthough the index is verified
> before dereferencing the pointer.
Addressing like this is UB already.
You could just move this:
> - if (legacy_serial_console < 0)
> - return 0;
to before
> - struct legacy_serial_info *info = &legacy_serial_infos[legacy_serial_console];
> - struct plat_serial8250_port *port = &legacy_serial_ports[legacy_serial_console];
and no other change is necessary.
Segher
WARNING: multiple messages have this Message-ID (diff)
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
pmenzel@molgen.mpg.de, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds
Date: Mon, 10 May 2021 16:14:44 -0500 [thread overview]
Message-ID: <20210510211444.GE10366@gate.crashing.org> (raw)
In-Reply-To: <d5e3c8e66bad3725d7d48d0e45c4b7eb7c02631d.1620455671.git.christophe.leroy@csgroup.eu>
On Sat, May 08, 2021 at 06:36:21AM +0000, Christophe Leroy wrote:
> UBSAN complains when a pointer is calculated with invalid
> 'legacy_serial_console' index, allthough the index is verified
> before dereferencing the pointer.
Addressing like this is UB already.
You could just move this:
> - if (legacy_serial_console < 0)
> - return 0;
to before
> - struct legacy_serial_info *info = &legacy_serial_infos[legacy_serial_console];
> - struct plat_serial8250_port *port = &legacy_serial_ports[legacy_serial_console];
and no other change is necessary.
Segher
next prev parent reply other threads:[~2021-05-10 21:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-08 6:36 [PATCH] powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds Christophe Leroy
2021-05-08 6:36 ` Christophe Leroy
2021-05-10 21:14 ` Segher Boessenkool [this message]
2021-05-10 21:14 ` Segher Boessenkool
2021-05-11 1:16 ` Michael Ellerman
2021-05-11 1:16 ` Michael Ellerman
2021-05-11 4:54 ` Christophe Leroy
2021-05-11 4:54 ` Christophe Leroy
2021-05-15 22:43 ` Michael Ellerman
2021-05-15 22:43 ` Michael Ellerman
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=20210510211444.GE10366@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=christophe.leroy@csgroup.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.org \
--cc=pmenzel@molgen.mpg.de \
/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.