This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: improve build-id mismatch error reporting


Hi Timo,

On Tue, 2011-09-13 at 10:54 +0300, Timo Juhani Lindfors wrote:
> Fortunately utsname()->version is available to us. It does not have the
> version number but instead the build date but now that I think of it
> this might be even better: people might recompile their custom kernels
> and forget to update the version number. I came up with
> 
> --- a/translate.cxx
> +++ b/translate.cxx
> @@ -1210,6 +1210,7 @@
>    // just in case modversions didn't.
>    o->newline() << "{";
>    o->newline(1) << "const char* release = UTS_RELEASE;";
> +  o->newline() << "const char* version = UTS_VERSION;";
>  
>    // NB: This UTS_RELEASE compile-time macro directly checks only that
>    // the compile-time kbuild tree matches the compile-time debuginfo/etc.
> @@ -1230,6 +1231,12 @@
>    o->newline() << "rc = -EINVAL;";
>    o->newline(-1) << "}";
>  
> +  o->newline() << "if (strcmp (utsname()->version, version)) {";
> +  o->newline(1) << "_stp_error (\"module version mismatch (%s vs %s)\", "
> +                << "version, utsname()->version);";
> +  o->newline() << "rc = -EINVAL;";
> +  o->newline(-1) << "}";
> +
>    // perform buildid-based checking if able
>    o->newline() << "if (_stp_module_check()) rc = -EINVAL;";
>  
> @@ -5878,6 +5885,7 @@
>        s.op->newline() << "#include <linux/utsname.h>";
>        s.op->newline() << "#include <linux/version.h>";
>        // s.op->newline() << "#include <linux/compile.h>";
> +      s.op->newline() << "#include <generated/compile.h>";
>        s.op->newline() << "#include \"loc2c-runtime.h\" ";
>        s.op->newline() << "#include \"access_process_vm.h\" ";
> 
> which gives output line
> 
> ERROR: module version mismatch (#1 SMP Sat Aug 27 16:21:11 UTC 2012 vs #1 SMP Sat Aug 27 16:21:11 UTC 2011)
> 
> What do you think?

I like the idea!
We should also include release/UTS_RELEASE in the output, it isn't the
package version, but at least gives a hint of the kernel version
involved.

Only issue is that as the patch already implies, in the past this header
was under include/linux/compile.h instead of
include/generated/compile.h. We might need a runtime/autoconf check for
that.

Thanks,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]