Re: printk feature for syzbot?
From: Sergey Senozhatsky
Date: Fri May 11 2018 - 02:22:03 EST
On (05/11/18 11:38), Tetsuo Handa wrote:
> >
> > So you basically want to have one more con_msg_format_flags? Do
> > you want to track a context which prints out a messages or the
> > context which "generated" the message? A CPU/task that stores
> > a logbuf entry - vprintk_emit() - is not always the same as the
> > CPU/task that prints it to consoles - console_unlock().
> >
>
> Well, below is the (partial) patch.
Hi,
Tetsuo, I will take a look a bit later, but at glance, there are several
ways to achieve what you are trying to do. The first one is the way you
did it - add additional buffer and make that context tracking info part of
the message body. Another one would be to extend struct printk_log and add
pid/cpu/flag there, which you then can convert into text in msg_print_text().
So far we talked about extending printk_log. Yet another one could be - add
vsprintf specifiers that would add pid/cpu/flag to the vsprintf-ed message.
You then can re-define pr_fmt, for instance, in the code you want to track
pr_fmt "%zZ" fmt, or somehow force printk to add that "%zZ" to every
message.
> By the way, when I tried to make similar change for printk_safe_log_store(),
> I noticed that printk_safe_log_store() is not safe because it is reusing
> the va_list variable after "goto again;". We need to use va_copy(), or
> we will get crash like an example shown below.
Oh, right. Can you send a patch?
-ss