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: <20160830093918.GA23693@swordfish>
Date:   Tue, 30 Aug 2016 18:39:18 +0900
From:   Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To:     Petr Mladek <pmladek@...e.com>
Cc:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Jan Kara <jack@...e.cz>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] printk/nmi: avoid direct printk()-s from
 __printk_nmi_flush()

On (08/30/16 11:04), Petr Mladek wrote:
> On Tue 2016-08-30 16:58:34, Sergey Senozhatsky wrote:
> > Petr,
> > one more question. Not related to the patch, but still related to NMI.
> > 
> > can NMI nest?
> 
> AFAIK, they cannot. NMIs should be disabled until iret is called.
> Therefore we should be on the safe side if iret is not called
> inside the NMI handler. But this should not happen because
> it would cause other problems, like using wrong return address.
> 
> Well, x86 nmi code has some hacks to handle exceptions inside
> NMI handlers that use iret. But printk_nmi_enter()/printk_nmi_exit()
> are never nested there. It is prevented by the nmi_state per-CPU
> variable. See do_nmi() in arch/x86/kernel/nmi.c.

yes, x86 has a per-cpu nmi_state to handle the case when NMI is
loosing its NMI context. But other arch-s, as far as I can see,
don't do that. Does it mean that we are safe only on x86?

this printk_func_saved thing is still will be needed, I think,
for alt_printk.

Example:

process abc
	printk()
		alt_printk_enter()
			this_cpu_write(printk_func, vprintk_alt);
->	NMI
	:	printk_nmi_enter()
	:		this_cpu_write(printk_func, vprintk_nmi);
	:	printk_nmi_exit()
	:		this_cpu_write(printk_func, vprintk_default);
	return NMI

		printk()  <<<<  nested printk -> vprintk_default(), set by nmi_exit()
		alt_printk_exit()
	...

	-ss

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ