linux-parisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [workqueue] check values of pwq and wq in print_worker_info() before use
@ 2013-10-01 20:35 Helge Deller
  2013-10-01 20:43 ` Tejun Heo
  0 siblings, 1 reply; 14+ messages in thread
From: Helge Deller @ 2013-10-01 20:35 UTC (permalink / raw)
  To: Tejun Heo, Libin, linux-kernel, linux-parisc, James Bottomley

print_worker_info() includes no validity check on the pwq and wq
pointers before handing them over to the probe_kernel_read() functions.

It seems that most architectures don't care about that, but at least on
the parisc architecture this leads to a kernel crash since accesses to
page zero are protected by the kernel for security reasons.

Fix this problem by verifying the contents of pwq and wq before usage.
Even if probe_kernel_read() usually prevents such crashes by disabling
page faults, clean code should always include such checks. 

Without this fix issuing "echo t > /proc/sysrq-trigger" will immediately
crash the Linux kernel on the parisc architecture.

CC: Tejun Heo <tj@kernel.org>
CC: Libin <huawei.libin@huawei.com>
CC: linux-parisc@vger.kernel.org
CC: James.Bottomley@HansenPartnership.com
Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 987293d..c03b47f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4512,8 +4512,10 @@ void print_worker_info(const char *log_lvl, struct task_struct *task)
 	 */
 	probe_kernel_read(&fn, &worker->current_func, sizeof(fn));
 	probe_kernel_read(&pwq, &worker->current_pwq, sizeof(pwq));
-	probe_kernel_read(&wq, &pwq->wq, sizeof(wq));
-	probe_kernel_read(name, wq->name, sizeof(name) - 1);
+	if (pwq)
+		probe_kernel_read(&wq, &pwq->wq, sizeof(wq));
+	if (wq)
+		probe_kernel_read(name, wq->name, sizeof(name) - 1);
 
 	/* copy worker description */
 	probe_kernel_read(&desc_valid, &worker->desc_valid, sizeof(desc_valid));

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-10-02  8:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-01 20:35 [PATCH] [workqueue] check values of pwq and wq in print_worker_info() before use Helge Deller
2013-10-01 20:43 ` Tejun Heo
2013-10-01 20:53   ` Helge Deller
2013-10-01 21:03     ` Tejun Heo
2013-10-01 21:07       ` Tejun Heo
2013-10-01 22:34         ` Helge Deller
2013-10-01 22:40           ` Tejun Heo
2013-10-01 22:47             ` Tejun Heo
2013-10-01 21:40   ` James Bottomley
2013-10-01 22:07     ` Helge Deller
2013-10-01 22:50       ` James Bottomley
2013-10-02  0:41         ` John David Anglin
2013-10-02  1:58         ` John David Anglin
2013-10-02  8:28         ` Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).