summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--translate.cxx25
2 files changed, 31 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f05f30c0..0a0d6bf2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-21 Frank Ch. Eigler <fche@elastic.org>
+
+ PR 3556.
+ * translate.cxx (emit_module_init): Emit code to check
+ system_utsname against translate-time version/machine strings.
+
2006-11-20 David Smith <dsmith@redhat.com>
* tapsets.cxx
diff --git a/translate.cxx b/translate.cxx
index d427fdba..96efa002 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -987,6 +987,30 @@ c_unparser::emit_module_init ()
o->newline() << "int i=0, j=0;"; // for derived_probe_group use
o->newline() << "const char *probe_point = \"\";";
+ // Compare actual and targeted kernel releases/machines. Sometimes
+ // one may install the incorrect debuginfo or -devel RPM, and try to
+ // run a probe compiled for a different version. Catch this early,
+ // just in case modversions didn't.
+ o->newline() << "if (strcmp (system_utsname.machine, "
+ << lex_cast_qstring (session->architecture) << ")) {";
+ o->newline(1) << "_stp_error (\"module machine mismatch (%s vs %s)\", "
+ << "system_utsname.machine, "
+ << lex_cast_qstring (session->architecture)
+ << ");";
+ o->newline() << "rc = -EINVAL;";
+ o->newline() << "goto out;";
+ o->newline(-1) << "}";
+
+ o->newline() << "if (strcmp (system_utsname.release, "
+ << lex_cast_qstring (session->kernel_release) << ")) {";
+ o->newline(1) << "_stp_error (\"module release mismatch (%s vs %s)\", "
+ << "system_utsname.release, "
+ << lex_cast_qstring (session->kernel_release)
+ << ");";
+ o->newline() << "rc = -EINVAL;";
+ o->newline() << "goto out;";
+ o->newline(-1) << "}";
+
o->newline() << "(void) probe_point;";
o->newline() << "(void) i;";
o->newline() << "(void) j;";
@@ -3977,6 +4001,7 @@ translate_pass (systemtap_session& s)
s.op->newline() << "#include <linux/delay.h>";
s.op->newline() << "#include <linux/profile.h>";
s.op->newline() << "#include <linux/random.h>";
+ s.op->newline() << "#include <linux/utsname.h>";
s.op->newline() << "#include \"loc2c-runtime.h\" ";
// XXX: old 2.6 kernel hack