lkml.org 
[lkml]   [2021]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds
From
Date


Le 11/05/2021 à 03:16, Michael Ellerman a écrit :
> Segher Boessenkool <segher@kernel.crashing.org> writes:
>
>> 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.
>
> Yeah I sent a v2 doing that, thanks.
>

I wanted something looking similar to setup_legacy_serial_console(), but of course this also works.

Christophe

\
 
 \ /
  Last update: 2021-05-11 06:54    [W:0.034 / U:1.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site