]> sourceware.org Git - systemtap.git/commitdiff
PR12612: compatibility with old staprun/stapio
authorFrank Ch. Eigler <fche@redhat.com>
Tue, 29 Mar 2011 13:33:53 +0000 (09:33 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Tue, 29 Mar 2011 13:33:53 +0000 (09:33 -0400)
commit 3abb860f changed the staprun<->runtime message format for
the STP_RELOCATE message, without regard for backward compatibility
for older/mismatching stapruns.  That leads to kernel errors and
no kernel probes and such nonsense.  Let's change the runtime to
interoperate both with old staprun and with the current one.

* runtime/transport/symbols.c (_stp_do_relocation): Also accept
  systemtap-1.3 level relocation message, if the incoming message
  size suggests.

runtime/transport/symbols.c
runtime/transport/transport_msgs.h

index e2f9fd65068bc5adf344d54d8c1bfa28e3dced40..d82fb7bced3447580a37595e0a783a8d03b24114 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- linux-c -*- 
  * symbols.c - stp symbol and module functions
  *
- * Copyright (C) Red Hat Inc, 2006-2009
+ * Copyright (C) Red Hat Inc, 2006-2011
  *
  * This file is part of systemtap, and is free software.  You can
  * redistribute it and/or modify it under the terms of the GNU General
 #define _STP_SYMBOLS_C_
 #include "../sym.h"
 
+/* PR12612: pre-commit-3abb860f values */
+
+#define STP13_MODULE_NAME_LEN 64
+#define STP13_SYMBOL_NAME_LEN 64
+struct _stp13_msg_relocation {
+        char module[STP13_MODULE_NAME_LEN];
+        char reloc[STP13_SYMBOL_NAME_LEN];
+        uint64_t address;
+};
+
 static void _stp_do_relocation(const char __user *buf, size_t count)
 {
   static struct _stp_msg_relocation msg; /* by protocol, never concurrently used */
+  static struct _stp13_msg_relocation msg13; /* ditto */
   unsigned mi, si;
 
-  if (sizeof(msg) != count)
-    {
-      errk ("STP_RELOCATE message size mismatch (%lu vs %lu)\n",
-            (long unsigned) sizeof(msg), (long unsigned) count);
+  /* PR12612: Let's try to be compatible with systemtap modules being
+     compiled by new systemtap, but loaded (staprun'd) by an older
+     systemtap runtime.  The only known incompatilibility is that we
+     get an older, smaller, relocation message.  So here we accept both
+     sizes. */
+  if (sizeof(msg) == count) { /* systemtap 1.4+ runtime */
+    if (unlikely(copy_from_user (& msg, buf, count)))
+            return;
+  } else if (sizeof(msg13) == count) { /* systemtap 1.3- runtime */
+    if (unlikely(copy_from_user (& msg13, buf, count)))
+            return;
+#if STP_MODULE_NAME_LEN <= STP13_MODULE_NAME_LEN
+#error "STP_MODULE_NAME_LEN should not be smaller than STP13_MODULE_NAME_LEN"
+#endif
+    strlcpy (msg.module, msg13.module, STP13_MODULE_NAME_LEN);
+    strlcpy (msg.reloc, msg13.reloc, STP13_MODULE_NAME_LEN);
+    msg.address = msg13.address;
+  } else {
+      errk ("STP_RELOCATE message size mismatch (%lu or %lu vs %lu)\n",
+            (long unsigned) sizeof(msg), (long unsigned) sizeof (msg13), (long unsigned) count);
       return;
-    }
-
-  if (unlikely(copy_from_user (& msg, buf, count)))
-    return;
+  }
 
   dbug_sym(2, "relocate (%s %s 0x%lx)\n", msg.module, msg.reloc, (unsigned long) msg.address);
 
index 6bea78b2e9262f493d329d3925ffd21c31fbd9a8..9ad50353ccbc48d22dd7e616e9df6ef42158a745 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- linux-c -*- 
  * transport_msgs.h - messages exchanged between module and userspace
  *
- * Copyright (C) Red Hat Inc, 2006-2010
+ * Copyright (C) Red Hat Inc, 2006-2011
  *
  * This file is part of systemtap, and is free software.  You can
  * redistribute it and/or modify it under the terms of the GNU General
@@ -9,6 +9,11 @@
  * later version.
  */
 
+/*
+ * NB: consider backward compatibility implications such as PR12612
+ * before changing existing message structures in any way.
+ */
+
 #define STP_MODULE_NAME_LEN 128
 #define STP_SYMBOL_NAME_LEN 128
 #define STP_TZ_NAME_LEN 64
This page took 0.030109 seconds and 5 git commands to generate.