sleep_on races in 2.4.0-test7-pre6

From: David Woodhouse (dwmw2@infradead.org)
Date: Tue Aug 22 2000 - 03:46:58 EST


The attached patch shows up three places where sleep_on_interruptible() is
used unsafely. I think it would be useful to include it at least briefly to
locate other abusers.

One could cause kswapd to miss wake-ups, which is not fatal but hardly
ideal. (mm/vmscan.c:604)

One could cause a user to miss events which arrive just as they're trying
to read /proc/sys/acpi/event (drivers/acpi/driver.c:162)

The third could cause the acpi thread to fail to wake up and service a
queued task (drivers/acpi/driver.c:333)

Index: kernel/sched.c
===================================================================
RCS file: /inst/cvs/linux/kernel/sched.c,v
retrieving revision 1.4.2.35
diff -u -r1.4.2.35 sched.c
--- kernel/sched.c 2000/08/05 16:53:08 1.4.2.35
+++ kernel/sched.c 2000/08/09 13:19:02
@@ -785,10 +785,18 @@
         __remove_wait_queue(q, &wait); \
         wq_write_unlock_irqrestore(&q->lock,flags);
 
+#define SLEEP_ON_LOCKCHECK \
+ if (current->lock_depth == -1) { \
+ printk(KERN_WARNING __FUNCTION__ " called without BKL held!\n"); \
+ BUG(); \
+ }
+
 void interruptible_sleep_on(wait_queue_head_t *q)
 {
         SLEEP_ON_VAR
 
+ SLEEP_ON_LOCKCHECK
+
         current->state = TASK_INTERRUPTIBLE;
 
         SLEEP_ON_HEAD
@@ -800,6 +808,8 @@
 {
         SLEEP_ON_VAR
 
+ SLEEP_ON_LOCKCHECK
+
         current->state = TASK_INTERRUPTIBLE;
 
         SLEEP_ON_HEAD
@@ -813,6 +823,8 @@
 {
         SLEEP_ON_VAR
         
+ SLEEP_ON_LOCKCHECK
+
         current->state = TASK_UNINTERRUPTIBLE;
 
         SLEEP_ON_HEAD
@@ -824,6 +836,8 @@
 {
         SLEEP_ON_VAR
         
+ SLEEP_ON_LOCKCHECK
+
         current->state = TASK_UNINTERRUPTIBLE;
 
         SLEEP_ON_HEAD

--
dwmw2

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Aug 23 2000 - 21:00:06 EST