Messages in this thread | | | From | Sergey Senozhatsky <> | Date | Tue, 9 Oct 2018 22:57:58 +0900 | Subject | Re: [PATCH v5 4/4] printk: Give error on attempt to set log buffer length to over 4G |
| |
On (10/09/18 15:05), Petr Mladek wrote: > > > > Yeah, I think we gonna have problems even with a 4G logbuf and a 32-bit > > user-space doing syslog(int len). > > > > I agree on the "not motivated enough" part ;) > > OK, I have pushed an updated patch that has the limit 2GB > into printk.git, for-4.20 branch. > > Note that it is slightly different than the yesterday's proposal. > I made a mistake in testing and still compared with UNIT_MAX. > > The pushed version can be seen at > https://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk.git/commit/?h=for-4.20&id=e6fe3e5b7d16e8f146a4ae7fe481bc6e97acde1e
---
> +#define LOG_BUF_LEN_MAX (u32)(1 << 31) [..] > + if (size > (u64)LOG_BUF_LEN_MAX) { > + size = (u64)LOG_BUF_LEN_MAX; > + pr_err("log_buf over 2G is not supported.\n"); > + }
Why not INT_MAX?
> + pr_info("log_buf_len: %u bytes\n", log_buf_len); > + pr_info("early log buf free: %u(%u%%)\n", > free, (free * 100) / __LOG_BUF_LEN);
Can 'free * 100' overflow?
-ss
| |