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: <20180618063738.GC27996@jagdpanzerIV>
Date:   Mon, 18 Jun 2018 15:37:38 +0900
From:   Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To:     Petr Mladek <pmladek@...e.com>
Cc:     Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
        Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        linux-kernel@...r.kernel.org, "4 . 13+" <stable@...r.kernel.org>
Subject: Re: [PATCH] printk/nmi: Prevent deadlock when serializing NMI
 backtraces

On (06/08/18 12:48), Petr Mladek wrote:
[..]
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index 6d7e800affd8..872fbdf8df26 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -148,9 +148,13 @@ void early_printk(const char *s, ...) { }
>  #ifdef CONFIG_PRINTK_NMI
>  extern void printk_nmi_enter(void);
>  extern void printk_nmi_exit(void);
> +extern void printk_nmi_direct_enter(void);
> +extern void printk_nmi_direct_exit(void);
>  #else
>  static inline void printk_nmi_enter(void) { }
>  static inline void printk_nmi_exit(void) { }
> +static void printk_nmi_direct_enter(void) { }
> +static void printk_nmi_direct_exit(void) { }

Can we have better names may be? Since direct printk_nmi is not
in fact always `direct'.

> +#ifdef CONFIG_PRINTK_NMI
> +__printf(1, 0) int vprintk_nmi(const char *fmt, va_list args);
> +#else
> +__printf(1, 0) int vprintk_nmi(const char *fmt, va_list args) { return 0; }
> +#endif

Hmm, printk_safe.c knows about printk.c, printk.c knows about
printk_safe.c.

>  __printf(1, 0) int vprintk_default(const char *fmt, va_list args);
>  __printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
>  __printf(1, 0) int vprintk_func(const char *fmt, va_list args);
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 247808333ba4..cf55bece43d9 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1845,7 +1845,13 @@ asmlinkage int vprintk_emit(int facility, int level,
>  	printk_delay();
>  
>  	/* This stops the holder of console_sem just where we want him */
> -	logbuf_lock_irqsave(flags);
> +	printk_safe_enter_irqsave(flags);
> +	if (in_nmi() && !raw_spin_trylock(&logbuf_lock)) {
> +		printed_len = vprintk_nmi(fmt, args);
> +		printk_safe_exit_irqrestore(flags);
> +		return printed_len;
> +	} else
> +		raw_spin_lock(&logbuf_lock);

OK... Can we do this in vprintk_func()? The race window should be super
tiny [if matters at all], but in exchange we don't have to mix nmi, printk,
printk_mni, etc.

So over all I understand why you did it this way. May be I'd prefer to
have less universal but shorter solution (e.g. modify only nmi_backtrace
function and put there "printk_nmi_restricted_buffer"), but I won't really
object your patch [unless I see some real issues with it].

	-ss

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ