Re: [PATCH] printk: fix buffer overflow potential for print_text()

From: Sven Schnelle
Date: Sun Jan 24 2021 - 04:01:02 EST


John Ogness <john.ogness@xxxxxxxxxxxxx> writes:

> Hi Sven,
>
> Thanks for the outstanding analysis!
>
> On 2021-01-23, Sven Schnelle <svens@xxxxxxxxxxxxx> wrote:
>>> 1401 if (buf_size > 0)
>>> 1402 text[len] = 0;
>>
>> I don't think i have really understood how all the printk magic works,
>> but using r->text_buf[len] seems to be the correct place to put the
>> zero byte in that case?
>
> Yes, you are correct! @text is pointing to the beginning of the
> currently processed line, not the beginning of the buffer.
>
> I will submit a patch to fix our recent fix (unless you would like to do
> that).

Please go ahead, thank you!