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>] [day] [month] [year] [list]
Message-Id: <1203133514.10893.28.camel@dhcp140.mvista.com>
Date:	Fri, 15 Feb 2008 19:45:14 -0800
From:	Min Zhang <mzhang@...sta.com>
To:	linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] Preempt realtime printk syslog

Add 50s timeout in do_syslog to poll printk from non-preemptible
section. printk is missing from syslog if from non-preemptible
section, because on PREEMPT_RT kernels, printk doesn't wake up syslogd
from non-preemptible section; see release_console_sem in
kernel/printk.c.

Tested by printk in module_init and insmod that kernel module. The
printk is in non-preemptive context because modules are loaded from
inside a realtime priority thread in a preemptive realtime kernel.

Signed-off-by: Min Zhang <mzhang@...sta.com>

Index: rt-2.6/kernel/printk.c
===================================================================
--- rt-2.6.orig/kernel/printk.c
+++ rt-2.6/kernel/printk.c
@@ -116,6 +116,12 @@ static int preferred_console = -1;
 /* Flag: console code may call schedule() */
 static int console_may_schedule;
 
+/* minimum time in jiffies between messages */
+int printk_ratelimit_jiffies = 5 * HZ;
+
+/* number of messages we send before ratelimiting */
+int printk_ratelimit_burst = 10;
+
 #ifdef CONFIG_PRINTK
 
 static char __log_buf[__LOG_BUF_LEN];
@@ -313,10 +319,26 @@ int do_syslog(int type, char __user *buf
 			error = -EFAULT;
 			goto out;
 		}
+#ifdef CONFIG_PREEMPT_RT
+ 		/*
+ 		 * On PREEMPT_RT kernels release_console_sem wakes us only if
+ 		 * in preemptible section, so timeout to poll for printk from
+ 		 * non-preemptible sections.
+ 		 */
+ 		i = printk_ratelimit_burst * printk_ratelimit_jiffies;
+ 		error = wait_event_interruptible_timeout(log_wait,
+ 							 (log_start - log_end),
+ 							 i);
+ 		if (error < 0)
+ 			goto out;
+ 		else
+ 			error = 0;
+#else
 		error = wait_event_interruptible(log_wait,
 							(log_start - log_end));
 		if (error)
 			goto out;
+#endif
 		i = 0;
 		spin_lock_irq(&logbuf_lock);
 		while (!error && (log_start != log_end) && i < len) {
@@ -1272,12 +1294,6 @@ int __printk_ratelimit(int ratelimit_jif
 }
 EXPORT_SYMBOL(__printk_ratelimit);
 
-/* minimum time in jiffies between messages */
-int printk_ratelimit_jiffies = 5 * HZ;
-
-/* number of messages we send before ratelimiting */
-int printk_ratelimit_burst = 10;
-
 int printk_ratelimit(void)
 {
 	return __printk_ratelimit(printk_ratelimit_jiffies,


--
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