lkml.org 
[lkml]   [2018]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] printk: fix integer overflow in setup_log_buf()
On (10/10/18 19:38), Sergey Senozhatsky wrote:
> The way we calculate free logbuf free space percentage
> overflows signed integer:
>
> int free;
>
> free = __LOG_BUF_LEN - log_next_idx;
> pr_info("early log buf free: %u(%u%%)\n",
> free, (free * 100) / __LOG_BUF_LEN);
>
> We support LOG_BUF_LEN of up to 2G, since setup_log_buf() is called
> during early init logbuf is mostly empty, so
>
> __LOG_BUF_LEN - log_next_idx
>
> is close to 2G. When we multiply it by 100, we overflow signed
> integer value range.

I'm really sorry. The commit message got totally messed up here.
What I meant was 1<<25. I used 2G as a boot param for testing to
set up a proper new_log_buf_len value. And somehow got confused,
I was in a hurry. I'll send a follow up with fixed commit message.

-ss

\
 
 \ /
  Last update: 2018-10-10 13:32    [W:0.047 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site