Re: [PATCH] printk: Add caller information to printk() output.
From: Tetsuo Handa
Date: Mon Dec 10 2018 - 09:01:50 EST
On 2018/12/10 22:09, Petr Mladek wrote:
>> +#ifdef CONFIG_PRINTK_FROM
>> +#define PREFIX_FROM_MAX 16
>> +#define PREFIX_MAX (32 + PREFIX_FROM_MAX)
>> +#define LOG_LINE_MAX (1024 - 32)
>
> This looks suspicious. We either need to limit LOG_LINE_MAX
> by the real PREFIX_MAX (48). Or we must make sure that
> the code is able to handle an eventual overflow.
Reducing LOG_LINE_MAX makes devkmsg_write() to return -EINVAL.
Is such user visible change acceptable?
> BTW: The limit 48 looks right. If I count correctly, the longest
> prefix might be:
>
> <2048>[4294967296,xxxxxx][T4294967296]
>
> 38 = 6+19+13
Theoretical max (based on variable's bit width) is
6 + 20 + 13 + 1 (for space) + 1 (for '\0') = 41.
We allocate 32 for "<2047>[18446744073.709551] ". Thus,
I chose 48 for "<2047>[18446744073.709551][T4294967295] ".