Re: [PATCH v3 1/2] printk: Fix panic caused by passing log_buf_len to command line

From: Sergey Senozhatsky
Date: Sat Sep 29 2018 - 04:26:28 EST


On (09/28/18 22:46), zhe.he@xxxxxxxxxxxxx wrote:
> This patch adds a check to prevent the panic and a check to report if someone is
> setting it over 4G.

OK, He Zhe, you are almost there.
Let's do the series the following way:

- four patches
- each change goes into a separate patch
- the first two patches Cc stable


patch #0 Cc stable

---
unsigned int size;

if (!str)
return -EINVAL;
size = memparse(str, &str);

---


patch #1 Cc stable

---

len = sprintf(text,
"** %llu printk messages dropped **\n",
log_first_seq - console_seq);

---


=====================================================================

patch #2

---

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

---


patch #3

---

if (size > UINT_MAX) {
size = UINT_MAX;
pr_err("log_buf over 4G is not supported.\n");
}

...
---

-ss