patch-2.1.116 linux/include/asm-alpha/processor.h

Next file: linux/include/asm-alpha/pyxis.h
Previous file: linux/include/asm-alpha/posix_types.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.115/linux/include/asm-alpha/processor.h linux/include/asm-alpha/processor.h
@@ -82,13 +82,23 @@
  * holds provided the thread blocked through a call to schedule() ($15
  * is the frame pointer in schedule() and $15 is saved at offset 48 by
  * entry.S:do_switch_stack).
+ *
+ * Under heavy swap load I've seen this loose in an ugly way.  So do
+ * some extra sanity checking on the ranges we expect these pointers
+ * to be in so that we can fail gracefully.  This is just for ps after
+ * all.  -- r~
  */
 extern inline unsigned long thread_saved_pc(struct thread_struct *t)
 {
-	unsigned long fp;
+	unsigned long fp, sp = t->ksp, base = (unsigned long)t;
+ 
+	if (sp > base && sp+6*8 < base + 16*1024) {
+		fp = ((unsigned long*)sp)[6];
+		if (fp > sp && fp < base + 16*1024)
+			return *(unsigned long *)fp;
+	}
 
-	fp = ((unsigned long*)t->ksp)[6];
-	return *(unsigned long*)fp;
+	return 0;
 }
 
 /*

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov