]> sourceware.org Git - systemtap.git/commitdiff
PR15793: numa addr_to_node(): protect __pa() call with virt_addr_valid()
authorFrank Ch. Eigler <fche@redhat.com>
Mon, 29 Jul 2013 18:16:01 +0000 (14:16 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Mon, 29 Jul 2013 18:17:25 +0000 (14:17 -0400)
Update test case to tolerate exception that may now be thrown by the
tapset function.

tapset/linux/memory.stp
testsuite/systemtap.examples/memory/numa_faults.stp

index 501f5732e070506a4ebdb95a4a014d4bb2de1dc0..c62d03ed65bb3b8b31c0fbdc41c630c356a4d605 100644 (file)
@@ -100,8 +100,15 @@ probe vm.pagefault.return =
  * node that the given address belongs to in a NUMA system.
  */
 function addr_to_node:long(addr:long) %{ /* pure */ 
-       int pfn = __pa(STAP_ARG_addr) >> PAGE_SHIFT;
        int nid;
+       int pfn;
+        if (! virt_addr_valid((void*) (uintptr_t) STAP_ARG_addr)) {
+            snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
+                      "invalid kernel virtual address 0x%p", (void *) (uintptr_t) STAP_ARG_addr);
+            CONTEXT->last_error = CONTEXT->error_buffer;
+            goto out;
+        }
+        pfn = __pa(STAP_ARG_addr) >> PAGE_SHIFT;
 #ifdef for_each_online_node
        for_each_online_node(nid)
 #else
index 34a0ace7798da2b73f87ddc016387a6c15ec1332..8b7ca1504c9cc1866a4f3d42e59193b530b4440f 100755 (executable)
@@ -3,11 +3,14 @@
 global execnames, page_faults, node_faults, nodes
 
 probe vm.pagefault {
-  p = pid(); n=addr_to_node(address)
+  p = pid();
   execnames[p] = execname()
   page_faults[p, write_access ? 1 : 0] <<< 1
-  node_faults[p, n] <<< 1
-  nodes[n] <<< 1
+  try {
+    n=addr_to_node(address)
+    node_faults[p, n] <<< 1
+    nodes[n] <<< 1
+  } catch { }
 }
 
 function print_pf () {
This page took 0.032208 seconds and 5 git commands to generate.