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]
Date:   Fri, 13 Oct 2017 09:30:31 -0400
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Petr Mladek <pmladek@...e.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        sergey.senozhatsky@...il.com, linux-kernel@...r.kernel.org,
        mingo@...nel.org, tglx@...utronix.de
Subject: Re: [PATCH 2/3] early_printk: Add force_early_printk kernel
 parameter

On Fri, 13 Oct 2017 15:06:09 +0200
Petr Mladek <pmladek@...e.com> wrote:
> > 
> > Can we even have !PRINTK && EARLY_PRINTK? If so it seems to me continued
> > usage of early_printk() is what makes most sense.  
> 
> Yes, !PRINTK && EARLY_PRINTK is possible at the moment. It makes some
> sense because EARLY_PRINTK needs only consoles and they are needed
> also for !PRINTK stuff.
> 
> We either should define force_early_printk only when
> PRINTK is enabled.

I think it makes sense to have force_early_printk depend on PRINTK and
EARLY_PRINTK.

 
> > The reason I did it like this and not use that function pointer thing is
> > that I didn't want to risk anybody hijacking my output ever.  
> 
> I understand. I think about refactoring the code so that all
> *printk*() variants call printk_func(). This function
> could then call the right printk implementation according
> to the context or global setting.
> 
> This way we could have all the logic on a single place and
> avoid the race.
> 
> Note that printk_func() is not longer a pointer. It is
> a function since the commit 099f1c84c0052ec1b2
> ("printk: introduce per-cpu safe_print seq buffer").

Yes, I agree with Petr here. Slapping the force printk into
printk_func() should have the same effect, as everything is hard coded
now:

asmlinkage __visible int printk(const char *fmt, ...)
{
	va_list args;
	int r;

	va_start(args, fmt);
	r = vprintk_func(fmt, args);
	va_end(args);

	return r;
}


__printf(1, 0) int vprintk_func(const char *fmt, va_list args)
{
	/* Use extra buffer in NMI when logbuf_lock is taken or in safe mode. */
	if (this_cpu_read(printk_context) & PRINTK_NMI_CONTEXT_MASK)
		return vprintk_nmi(fmt, args);

	/* Use extra buffer to prevent a recursion deadlock in safe mode. */
	if (this_cpu_read(printk_context) & PRINTK_SAFE_CONTEXT_MASK)
		return vprintk_safe(fmt, args);

	/*
	 * Use the main logbuf when logbuf_lock is available in NMI.
	 * But avoid calling console drivers that might have their own locks.
	 */
	if (this_cpu_read(printk_context) & PRINTK_NMI_DEFERRED_CONTEXT_MASK)
		return vprintk_deferred(fmt, args);

	/* No obstacles. */
	return vprintk_default(fmt, args);
}

Thus putting in the call to early_printk() at the very beginning of
vprintk_func() would have the result that Peter would like.

-- Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ