You need to sign in or sign up before continuing.
提交 f03a0118 编写于 作者: J John Ogness 提交者: Zheng Zengkai

printk: ringbuffer: fix line counting

stable inclusion
from stable-5.10.11
commit cf3cca5f1580ce846e36c32db2c125199dca2d86
bugzilla: 47621

--------------------------------

[ Upstream commit 668af87f ]

Counting text lines in a record simply involves counting the number
of newline characters (+1). However, it is searching the full data
block for newline characters, even though the text data can be (and
often is) a subset of that area. Since the extra area in the data
block was never initialized, the result is that extra newlines may
be seen and counted.

Restrict newline searching to the text data length.

Fixes: b6cf8b3f ("printk: add lockless ringbuffer")
Signed-off-by: NJohn Ogness <john.ogness@linutronix.de>
Reviewed-by: NPetr Mladek <pmladek@suse.com>
Acked-by: NSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: NPetr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20210113144234.6545-1-john.ogness@linutronix.deSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 bcb415c4
...@@ -1720,7 +1720,7 @@ static bool copy_data(struct prb_data_ring *data_ring, ...@@ -1720,7 +1720,7 @@ static bool copy_data(struct prb_data_ring *data_ring,
/* Caller interested in the line count? */ /* Caller interested in the line count? */
if (line_count) if (line_count)
*line_count = count_lines(data, data_size); *line_count = count_lines(data, len);
/* Caller interested in the data content? */ /* Caller interested in the data content? */
if (!buf || !buf_size) if (!buf || !buf_size)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册