* [PATCH v2] printk: fix kernel msg leakage in syslog_print_all function;
@ 2022-05-05 2:52 Tao Lan
2022-05-05 7:13 ` Petr Mladek
0 siblings, 1 reply; 2+ messages in thread
From: Tao Lan @ 2022-05-05 2:52 UTC (permalink / raw)
To: pmladek, senozhatsky, rostedt, john.ogness; +Cc: linux-kernel, taolan
This function applies for memory but does not initialize the memory,and
then invokes copy_to_user to copy the memory to the user space, which
causes kernel information leaks.
[ 148.439660] kernel memory leak value 0xffffff80aed972bc at
0xffffffd37f00a000 to 0x704b883e74
Signed-off-by: Tao Lan <taolan@huawei.com>
---
v2: to change to my correct name.
kernel/printk/printk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index da03c15ecc89..22d7d821909d 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1591,7 +1591,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
u64 seq;
bool time;
- text = kmalloc(CONSOLE_LOG_MAX, GFP_KERNEL);
+ text = kzalloc(CONSOLE_LOG_MAX, GFP_KERNEL);
if (!text)
return -ENOMEM;
--
2.18.0.huawei.25
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] printk: fix kernel msg leakage in syslog_print_all function;
2022-05-05 2:52 [PATCH v2] printk: fix kernel msg leakage in syslog_print_all function; Tao Lan
@ 2022-05-05 7:13 ` Petr Mladek
0 siblings, 0 replies; 2+ messages in thread
From: Petr Mladek @ 2022-05-05 7:13 UTC (permalink / raw)
To: Tao Lan; +Cc: senozhatsky, rostedt, john.ogness, linux-kernel
On Thu 2022-05-05 02:52:10, Tao Lan wrote:
> This function applies for memory but does not initialize the memory,and
> then invokes copy_to_user to copy the memory to the user space, which
> causes kernel information leaks.
It should not happen. copy_to_user() is used this way:
textlen = record_print_text(&r, true, time);
if (copy_to_user(buf + len, text, textlen))
It means that only @textlen bytes should be copied to the user space.
It is the length of the message read from the log buffer by
record_print_text().
> [ 148.439660] kernel memory leak value 0xffffff80aed972bc at
> 0xffffffd37f00a000 to 0x704b883e74
How did you produce this message, please?
Best Regards,
Petr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-05 7:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 2:52 [PATCH v2] printk: fix kernel msg leakage in syslog_print_all function; Tao Lan
2022-05-05 7:13 ` Petr Mladek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).