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]
Date:	Thu, 11 Dec 2014 06:33:07 -0500
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Ingo Molnar <mingo@...nel.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Jiri Kosina <jkosina@...e.cz>, Petr Mladek <pmladek@...e.cz>
Subject: Re: [GIT PULL] tracing/NMI/printk: Use seq_buf for safe printing
 from NMI context

On Wed, 10 Dec 2014 21:29:40 -0800
Linus Torvalds <torvalds@...ux-foundation.org> wrote:

> On Wed, Dec 10, 2014 at 8:20 PM, Linus Torvalds
> <torvalds@...ux-foundation.org> wrote:
> >
> > Would it perhaps be possible/reasonable to also use this to get rid of
> > the horrible "early_printk()" stuff [...]
> 
> Another question: the "preempt_disable/enable()" around the use of the
> per-cpu vprintk_func thing seems dubious.
> 
> Why do I say that? I think it cannot possibly make sense. Anybody who
> sets that function pointer to any per-cpu value has to disable
> preemption for that to make sense, so doing it inside the printk()
> paths seems dubious at best.
> 
> No?

So you are saying that anytime the printk_func is not the default, the
caller had to have disable preemption? Even if the caller changes all
per cpu calls, it is probably still safe as other cpus will be either
using the default or the one that is going to be the "default" (I say
that as being global).

Thus something like this?

-- Steve

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 5af2b8bc88f0..9b896e7a50a9 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1859,10 +1859,16 @@ asmlinkage __visible int printk(const char *fmt, ...)
 	int r;
 
 	va_start(args, fmt);
-	preempt_disable();
+
+	/*
+	 * If a caller overrides the per_cpu printk_func, then it needs
+	 * to disable preemption when calling printk(). Otherwise
+	 * the printk_func should be set to the default. No need to
+	 * disable preemption here.
+	 */
 	vprintk_func = this_cpu_read(printk_func);
 	r = vprintk_func(fmt, args);
-	preempt_enable();
+
 	va_end(args);
 
 	return r;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ