On 2020-12-07, John Ogness <john.ogn...@linutronix.de> wrote:
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index e1f068677a74..f3c0fcc3163f 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
[...]
>  int vprintk_store(int facility, int level,
>                 const struct dev_printk_info *dev_info,
>                 const char *fmt, va_list args)
>  {
>       const u32 caller_id = printk_caller_id();
> -     static char textbuf[LOG_LINE_MAX];
>       struct prb_reserved_entry e;
>       enum log_flags lflags = 0;
>       struct printk_record r;
>       u16 trunc_msg_len = 0;
> -     char *text = textbuf;
> +     char prefix_buf[8];
> +     va_list args2;
>       u16 text_len;
> +     int ret = 0;
>       u64 ts_nsec;
>  
>       /*
> @@ -1884,35 +1951,21 @@ int vprintk_store(int facility, int level,
>        */
>       ts_nsec = local_clock();
>  
> +     va_copy(args2, args);
> +
>       /*
>        * The printf needs to come first; we need the syslog
>        * prefix which might be passed-in as a parameter.
>        */
> -     text_len = vscnprintf(text, sizeof(textbuf), fmt, args);
> +     text_len = vsnprintf(&prefix_buf[0], sizeof(prefix_buf), fmt, args) + 1;
> +     if (text_len > CONSOLE_LOG_MAX)
> +             text_len = CONSOLE_LOG_MAX;

LOG_LINE_MAX should be the limit. That was the size of the static
@textbuf.

John Ogness

Reply via email to