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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161125142855.GI24103@pathway.suse.cz>
Date:   Fri, 25 Nov 2016 15:28:55 +0100
From:   Petr Mladek <pmladek@...e.com>
To:     Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>, Jan Kara <jack@...e.cz>,
        Tejun Heo <tj@...nel.org>, Calvin Owens <calvinowens@...com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Mel Gorman <mgorman@...hsingularity.net>,
        Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Laura Abbott <labbott@...hat.com>,
        Andy Lutomirski <luto@...nel.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Kees Cook <keescook@...omium.org>,
        linux-kernel@...r.kernel.org,
        Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Subject: Re: [RFC][PATCHv4 5/6] printk: use printk_safe buffers

On Fri 2016-10-28 00:49:32, Sergey Senozhatsky wrote:
> Use printk_safe per-CPU buffers in in printk recursion-prone blocks:
> -- around logbuf_lock protected sections in vprintk_emit() and
>    console_unlock()
> -- around down_trylock_console_sem() and up_console_sem()
> 
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 4675b8d..5907e92 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1823,13 +1837,12 @@ asmlinkage int vprintk_emit(int facility, int level,
>  		 */
>  		if (!oops_in_progress && !lockdep_recursing(current))
> {
>  			recursion_bug = true;
> -			local_irq_restore(flags);
> +			printk_safe_exit(flags);
>  			return 0;
>  		}
>  		zap_locks();
>  	}
>  
> -	lockdep_off();

I really like this patch. The only small problem is that it enables
lockdep and it does not explain why it is safe. The change itself
looks fine but it took me some time to prove why. IMHO, it is
worth a comment.

One thing is printk() recursion caused by lockdep warning
triggered from inside vprintk_emit(). It is safe because
the critical sections are guarded by printk_safe_enter()/exit()
now.

Another thing is lockdep recursion caused by catching another lockdep
issue when printing warning about the first one. This is safe
because lockdep protects itself. First, it sets and checks
current->lockdep_recursion around the critical sections.
Second, further checks are disabled entirely once first
lockdep issue is found.

If you add some comments about lockdep, feel free to use:

Reviewed-by: Petr Mladek <pmladek@...e.com>

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ