osi-probe-harder-20070213
[openafs.git] / src / afs / LINUX / osi_probe.c
index 3b30fdd..16b5322 100644 (file)
@@ -59,7 +59,9 @@
 #include "afsincludes.h"
 #endif
 #include <linux/version.h>
+#ifdef CONFIG_H_EXISTS
 #include <linux/config.h>
+#endif
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <linux/unistd.h>
@@ -512,7 +514,7 @@ static probectl main_probe = {
     (unsigned long)&sys_close,
 #elif defined(AFS_AMD64_LINUX20_ENV)
     /* On this platform, it's in a different section! */
-    (unsigned long)&tasklist_lock,
+    (unsigned long)&generic_ro_fops,
 #else
     (unsigned long)&init_mm,
 #endif
@@ -534,7 +536,7 @@ static probectl main_probe = {
     0x1fffff,
     0x30000,
 #elif defined(AFS_AMD64_LINUX20_ENV)
-    (unsigned long)(&tasklist_lock) - 0x30000,
+    (unsigned long)(&generic_ro_fops) - 0x30000,
     0,
     0x6000,
 #elif defined(AFS_PPC64_LINUX26_ENV)
@@ -553,9 +555,9 @@ static probectl main_probe = {
 
 #ifdef AFS_LINUX26_ENV
     (unsigned long)scsi_command_size,
-    (unsigned long)scsi_command_size,
+    (unsigned long)scsi_command_size - 0x10000,
     0x3ffff,
-    0x30000,
+    0x40000,
 #else
     0, 0, 0, 0,
 #endif
@@ -651,9 +653,9 @@ static probectl ia32_probe = {
 
 #ifdef AFS_LINUX26_ENV
     (unsigned long)scsi_command_size,
-    (unsigned long)scsi_command_size,
+    (unsigned long)scsi_command_size - 0x10000,
     0x3ffff,
-    0x30000,
+    0x40000,
 #else
     0, 0, 0, 0,
 #endif
@@ -790,9 +792,9 @@ static probectl sct32_probe = {
 
 #ifdef AFS_LINUX26_ENV
     (unsigned long)scsi_command_size,
-    (unsigned long)scsi_command_size,
+    (unsigned long)scsi_command_size - 0x10000,
     0x3ffff,
-    0x30000,
+    0x40000,
 #else
     0, 0, 0, 0,
 #endif
@@ -885,9 +887,9 @@ static probectl emu_probe = {
 
 #ifdef AFS_LINUX26_ENV
     (unsigned long)scsi_command_size,
-    (unsigned long)scsi_command_size,
+    (unsigned long)scsi_command_size - 0x10000,
     0x3ffff,
-    0x30000,
+    0x40000,
 #else
     0, 0, 0, 0,
 #endif
@@ -1008,6 +1010,17 @@ static void *try(probectl *P, tryctl *T, PROBETYPE *aptr,
 #else
        ptr = aptr;
 #endif
+       if ((unsigned long)ptr < init_mm.start_code ||
+#if defined(AFS_AMD64_LINUX20_ENV)
+               (unsigned long)ptr > init_mm.brk)
+#else
+               (unsigned long)ptr > init_mm.end_data)
+#endif
+       {
+/*          printk("address 0x%lx (from 0x%lx %d) is out of range in check_table. wtf?\n", (unsigned long)x, (unsigned long)ptr, i);*/
+            continue;
+       }
+
        ret = check_table(P, ptr);
        if (ret >= 0) {
            /* return value is number of entries to skip */
@@ -1112,6 +1125,16 @@ static void *try_harder(probectl *P, PROBETYPE *ptr, unsigned long datalen)
        printk("<7>osi_probe: %s                      try_harder\n", P->symbol);
 #endif
     for (offset = 0; offset < datalen; offset++, ptr++) {
+        if ((unsigned long)ptr < init_mm.start_code ||
+#if defined(AFS_AMD64_LINUX20_ENV)
+               (unsigned long)ptr > init_mm.brk)
+#else
+               (unsigned long)ptr > init_mm.end_data)
+#endif
+       {
+/*          printk("address 0x%lx (from 0x%lx %d) is out of range in check_table. wtf?\n", (unsigned long)x, (unsigned long)ptr, i);*/
+            continue;
+       }
        ret = check_table(P, ptr);
         if (ret >= 0) {
             /* return value is number of entries to skip */