From 3cb8cba0f784cb9402a143020c6ef14d1d67601a Mon Sep 17 00:00:00 2001 From: fche Date: Tue, 21 Nov 2006 16:48:05 +0000 Subject: 2006-11-21 Frank Ch. Eigler PR 3556. * translate.cxx (emit_module_init): Emit code to check system_utsname against translate-time version/machine strings. --- ChangeLog | 6 ++++++ translate.cxx | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/ChangeLog b/ChangeLog index f05f30c0..0a0d6bf2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-11-21 Frank Ch. Eigler + + PR 3556. + * translate.cxx (emit_module_init): Emit code to check + system_utsname against translate-time version/machine strings. + 2006-11-20 David Smith * 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 "; s.op->newline() << "#include "; s.op->newline() << "#include "; + s.op->newline() << "#include "; s.op->newline() << "#include \"loc2c-runtime.h\" "; // XXX: old 2.6 kernel hack -- cgit