Author: markj
Date: Tue Dec 20 18:25:41 2016
New Revision: 310332
URL: https://svnweb.freebsd.org/changeset/base/310332

Log:
  Avoid modifying the object string table when patching USDT probes.
  
  dtrace converts pairs of consecutive underscores in a probe name to dashes.
  When dtrace -G processes relocations corresponding to USDT probe sites, it
  performs this conversion on the corresponding symbol names prior to looking
  up the resulting probe names in the USDT provider definition. However, in
  so doing it would actually modify the input object's string table, which
  breaks the string suffix merging done by recent binutils. Because we don't
  care about the symbol name once the probe site is recorded, just perform the
  probe lookup using a temporary copy.
  
  Reported by:  hrs, swills
  MFC after:    3 weeks

Modified:
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c

Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c        Tue Dec 
20 18:09:59 2016        (r310331)
+++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c        Tue Dec 
20 18:25:41 2016        (r310332)
@@ -1223,6 +1223,7 @@ process_obj(dtrace_hdl_t *dtp, const cha
        static const char dt_enabled[] = "enabled";
        static const char dt_symprefix[] = "$dtrace";
        static const char dt_symfmt[] = "%s%ld.%s";
+       char probename[DTRACE_NAMELEN];
        int fd, i, ndx, eprobe, mod = 0;
        Elf *elf = NULL;
        GElf_Ehdr ehdr;
@@ -1576,8 +1577,6 @@ process_obj(dtrace_hdl_t *dtp, const cha
                        bcopy(s, pname, p - s);
                        pname[p - s] = '\0';
 
-                       p = strhyphenate(p + 3); /* strlen("___") */
-
                        if (dt_symtab_lookup(data_sym, isym, rela.r_offset,
                            shdr_rel.sh_info, &fsym,
                            (emachine1 == EM_PPC64), elf) != 0)
@@ -1628,10 +1627,14 @@ process_obj(dtrace_hdl_t *dtp, const cha
                                    "no such provider %s", pname));
                        }
 
-                       if ((prp = dt_probe_lookup(pvp, p)) == NULL) {
+                       if (strlcpy(probename, p + 3, sizeof (probename)) >=
+                           sizeof (probename))
                                return (dt_link_error(dtp, elf, fd, bufs,
-                                   "no such probe %s", p));
-                       }
+                                   "invalid probe name %s", probename));
+                       (void) strhyphenate(probename);
+                       if ((prp = dt_probe_lookup(pvp, probename)) == NULL)
+                               return (dt_link_error(dtp, elf, fd, bufs,
+                                   "no such probe %s", probename));
 
                        assert(fsym.st_value <= rela.r_offset);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to