Bug 24619 - mudflap instrumentation of dlopen is incorrect
Summary: mudflap instrumentation of dlopen is incorrect
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: libmudflap (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.9.0
Assignee: Frank Ch. Eigler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-01 17:45 UTC by Debian GCC Maintainers
Modified: 2013-11-10 05:54 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-07-02 23:38:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2005-11-01 17:45:49 UTC
[forwarded from http://bugs.debian.org/336511]

bug submitter writes:

If mudflap is used to instrument a program using dlopen, and the program
(assuming it is compiled with -rdynamic) loads itself by passing NULL for the
path to dlopen, the program will crash unconditionally; that is, regardless of
the options passed to mudflap, so long as instrumentation is enabled.

This is because (at least with GNU/Linux) it is valid to pass a NULL pointer as
the path argument to dlopen, and the instrumentation code unconditionally uses
strlen on that pointer, without checking first if it is NULL.

I have included the following patch, which may help fix the problem.  I have not
tested it, but it should work.  As always, it is "as is", with no warranty of
any kind.  The patch is against svn HEAD (r104588).

- --- mf-hooks2.c.orig  2005-10-30 20:35:44.000000000 +0000
+++ mf-hooks2.c 2005-10-30 20:37:38.000000000 +0000
@@ -1679,8 +1679,10 @@ WRAPPER2(void *, dlopen, const char *pat
   void *p;
   size_t n;
   TRACE ("%s\n", __PRETTY_FUNCTION__);
- -  n = strlen (path);
- -  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "dlopen path");
+  if (NULL != path) {
+    n = strlen (path);
+    MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "dlopen path");
+  }
   p = dlopen (path, flags);
   if (NULL != p) {
 #ifdef MF_REGISTER_dlopen
Comment 1 Andrew Pinski 2005-11-01 17:48:24 UTC
I think this is a GNU extension or one which came in from elf.
Comment 2 Andrew Pinski 2005-11-01 22:46:41 UTC
Confirmed.
Comment 3 Frank Ch. Eigler 2012-09-19 15:54:22 UTC
(test only, please ignore)
Comment 4 Andrew Pinski 2013-11-10 05:54:32 UTC
fmudflap support has been removed.