lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANpmjNOXJ6B59bxObf5LZwr5b=fAnpf7d=T6=NCAD-Sq7MA23w@mail.gmail.com>
Date:   Thu, 6 May 2021 13:10:58 +0200
From:   Marco Elver <elver@...gle.com>
To:     Alexander Potapenko <glider@...gle.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Petr Mladek <pmladek@...e.com>, Ingo Molnar <mingo@...nel.org>,
        bo.he@...el.com, yanmin_zhang@...ux.intel.com,
        psodagud@...cinc.com, Dmitry Vyukov <dvyukov@...gle.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Andrey Ryabinin <ryabinin.a.a@...il.com>, he@...gle.com
Subject: Re: [PATCH v2 1/2] printk: introduce dump_stack_lvl()

On Thu, 6 May 2021 at 12:54, Alexander Potapenko <glider@...gle.com> wrote:
>
> dump_stack() is used for many different cases, which may require a log
> level consistent with other kernel messages surrounding the dump_stack()
> call.
> Without that, certain systems that are configured to ignore the default
> level messages will miss stack traces in critical error reports.
>
> This patch introduces dump_stack_lvl() that behaves similarly to
> dump_stack(), but accepts a custom log level.
> The old dump_stack() becomes equal to dump_stack_lvl(KERN_DEFAULT).
>
> A somewhat similar patch has been proposed in 2012:
> https://lore.kernel.org/lkml/1332493269.2359.9.camel@hebo/
> , but wasn't merged.
>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Petr Mladek <pmladek@...e.com>
> Cc: Ingo Molnar <mingo@...nel.org>
> Cc: he, bo <bo.he@...el.com>
> Cc: Yanmin Zhang <yanmin_zhang@...ux.intel.com>
> Cc: Prasad Sodagudi <psodagud@...cinc.com>
> Cc: Dmitry Vyukov <dvyukov@...gle.com>
> Cc: Marco Elver <elver@...gle.com>
> Cc: linux-kernel@...r.kernel.org
> Signed-off-by: Alexander Potapenko <glider@...gle.com>

Reviewed-by: Marco Elver <elver@...gle.com>


> ---
>
> v2:
>  -- export dump_stack_lvl() (spotted by Marco Elver)
> ---
>  include/linux/printk.h |  1 +
>  lib/dump_stack.c       | 20 +++++++++++++-------
>  2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index fe7eb2351610..abe274305d79 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -206,6 +206,7 @@ void __init setup_log_buf(int early);
>  __printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...);
>  void dump_stack_print_info(const char *log_lvl);
>  void show_regs_print_info(const char *log_lvl);
> +extern asmlinkage void dump_stack_lvl(const char *log_lvl) __cold;
>  extern asmlinkage void dump_stack(void) __cold;
>  extern void printk_safe_flush(void);
>  extern void printk_safe_flush_on_panic(void);
> diff --git a/lib/dump_stack.c b/lib/dump_stack.c
> index f5a33b6f773f..586e3f2c6a15 100644
> --- a/lib/dump_stack.c
> +++ b/lib/dump_stack.c
> @@ -73,10 +73,10 @@ void show_regs_print_info(const char *log_lvl)
>         dump_stack_print_info(log_lvl);
>  }
>
> -static void __dump_stack(void)
> +static void __dump_stack(const char *log_lvl)
>  {
> -       dump_stack_print_info(KERN_DEFAULT);
> -       show_stack(NULL, NULL, KERN_DEFAULT);
> +       dump_stack_print_info(log_lvl);
> +       show_stack(NULL, NULL, log_lvl);
>  }
>
>  /**
> @@ -87,7 +87,7 @@ static void __dump_stack(void)
>  #ifdef CONFIG_SMP
>  static atomic_t dump_lock = ATOMIC_INIT(-1);
>
> -asmlinkage __visible void dump_stack(void)
> +asmlinkage __visible void dump_stack_lvl(const char *log_lvl)
>  {
>         unsigned long flags;
>         int was_locked;
> @@ -117,7 +117,7 @@ asmlinkage __visible void dump_stack(void)
>                 goto retry;
>         }
>
> -       __dump_stack();
> +       __dump_stack(log_lvl);
>
>         if (!was_locked)
>                 atomic_set(&dump_lock, -1);
> @@ -125,9 +125,15 @@ asmlinkage __visible void dump_stack(void)
>         local_irq_restore(flags);
>  }
>  #else
> -asmlinkage __visible void dump_stack(void)
> +asmlinkage __visible void dump_stack_lvl(const char *log_lvl)
>  {
> -       __dump_stack();
> +       __dump_stack(log_lvl);
>  }
>  #endif
> +EXPORT_SYMBOL(dump_stack_lvl);
> +
> +asmlinkage __visible void dump_stack(void)
> +{
> +       dump_stack_lvl(KERN_DEFAULT);
> +}
>  EXPORT_SYMBOL(dump_stack);
> --
> 2.31.1.527.g47e6f16901-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ