[patch] /proc deadlock 2.3.22

Andrea Arcangeli (andrea@suse.de)
Mon, 18 Oct 1999 01:53:45 +0200 (CEST)


Roy reported me he was experiencing deadlocking using fuser in 2.3.22.

I was running a copy_to_user while I was taking hold the mmap semaphore of
the current process... (woops). This is the fix against 2.3.22:

--- 2.3.22/fs/proc/array.c Sat Oct 16 03:34:52 1999
+++ /tmp/array.c Mon Oct 18 01:31:48 1999
@@ -1262,6 +1262,7 @@

down(&mm->mmap_sem);
/* quickly go to line "lineno" */
+ process_next_line:
for (map = mm->mmap, i = 0; map && (i < lineno); map = map->vm_next, i++)
continue;

@@ -1317,6 +1318,9 @@
lineno++;
continue; /* we haven't slept */
}
+ /* release semaphore to avoid deadlocking in the copy-user
+ faults */
+ up(&mm->mmap_sem);

i = len-column;
if (i > count)
@@ -1330,9 +1334,11 @@
lineno++;
}

+ down(&mm->mmap_sem);
/* done? */
if (count == 0)
break;
+ goto process_next_line;
}
up(&mm->mmap_sem);

Thanks to Rod to point out to me the problem.

Andrea

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