Author: markj
Date: Mon Nov 17 22:22:16 2014
New Revision: 274637
URL: https://svnweb.freebsd.org/changeset/base/274637

Log:
  DTrace imposes a 128-byte limit on the length of the function component of
  a probe name. When dtrace -G builds up a DOF section for the specified
  provider(s), the probe function names are truncated to fit in this limit.
  The DOF is later used to build the symbol table for the generated object
  file, so the table can end up with truncated references, causing link
  errors.
  
  Instead of potentially truncating symbol table entries, write the full
  function name to the DOF string table and allow the kernel to enforce the
  128-byte function name limit when a process attempts to load its DOF.
  
  PR:           194757
  Differential Revision:        https://reviews.freebsd.org/D1175
  Reviewed by:  rpaulo
  MFC after:    2 weeks

Modified:
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h

Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c Mon Nov 17 
21:01:35 2014        (r274636)
+++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c Mon Nov 17 
22:22:16 2014        (r274637)
@@ -469,7 +469,7 @@ dof_add_probe(dt_idhash_t *dhp, dt_ident
                 * locally so an alternate symbol is added for the purpose
                 * of this relocation.
                 */
-               if (pip->pi_rname[0] == '\0')
+               if (pip->pi_rname == NULL)
                        dofr.dofr_name = dofpr.dofpr_func;
                else
                        dofr.dofr_name = dof_add_string(ddo, pip->pi_rname);

Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c    Mon Nov 
17 21:01:35 2014        (r274636)
+++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c    Mon Nov 
17 22:22:16 2014        (r274637)
@@ -520,6 +520,8 @@ dt_probe_destroy(dt_probe_t *prp)
 
        for (pip = prp->pr_inst; pip != NULL; pip = pip_next) {
                pip_next = pip->pi_next;
+               dt_free(dtp, pip->pi_rname);
+               dt_free(dtp, pip->pi_fname);
                dt_free(dtp, pip->pi_offs);
                dt_free(dtp, pip->pi_enoffs);
                dt_free(dtp, pip);
@@ -552,28 +554,18 @@ dt_probe_define(dt_provider_t *pvp, dt_p
                if ((pip = dt_zalloc(dtp, sizeof (*pip))) == NULL)
                        return (-1);
 
-               if ((pip->pi_offs = dt_zalloc(dtp,
-                   sizeof (uint32_t))) == NULL) {
-                       dt_free(dtp, pip);
-                       return (-1);
-               }
+               if ((pip->pi_offs = dt_zalloc(dtp, sizeof (uint32_t))) == NULL)
+                       goto nomem;
 
                if ((pip->pi_enoffs = dt_zalloc(dtp,
-                   sizeof (uint32_t))) == NULL) {
-                       dt_free(dtp, pip->pi_offs);
-                       dt_free(dtp, pip);
-                       return (-1);
-               }
+                   sizeof (uint32_t))) == NULL)
+                       goto nomem;
 
-               (void) strlcpy(pip->pi_fname, fname, sizeof (pip->pi_fname));
-               if (rname != NULL) {
-                       if (strlen(rname) + 1 > sizeof (pip->pi_rname)) {
-                               dt_free(dtp, pip->pi_offs);
-                               dt_free(dtp, pip);
-                               return (dt_set_errno(dtp, EDT_COMPILER));
-                       }
-                       (void) strcpy(pip->pi_rname, rname);
-               }
+               if ((pip->pi_fname = strdup(fname)) == NULL)
+                       goto nomem;
+
+               if (rname != NULL && (pip->pi_rname = strdup(rname)) == NULL)
+                       goto nomem;
 
                pip->pi_noffs = 0;
                pip->pi_maxoffs = 1;
@@ -618,6 +610,13 @@ dt_probe_define(dt_provider_t *pvp, dt_p
        (*offs)[(*noffs)++] = offset;
 
        return (0);
+
+nomem:
+       dt_free(dtp, pip->pi_fname);
+       dt_free(dtp, pip->pi_enoffs);
+       dt_free(dtp, pip->pi_offs);
+       dt_free(dtp, pip);
+       return (dt_set_errno(dtp, EDT_NOMEM));
 }
 
 /*

Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h    Mon Nov 
17 21:01:35 2014        (r274636)
+++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h    Mon Nov 
17 22:22:16 2014        (r274637)
@@ -64,8 +64,8 @@ typedef struct dt_probe_iter {
 } dt_probe_iter_t;
 
 typedef struct dt_probe_instance {
-       char pi_fname[DTRACE_FUNCNAMELEN]; /* function name */
-       char pi_rname[DTRACE_FUNCNAMELEN + 20]; /* mangled relocation name */
+       char *pi_fname;                 /* function name */
+       char *pi_rname;                 /* mangled relocation name */
        uint32_t *pi_offs;              /* offsets into the function */
        uint32_t *pi_enoffs;            /* is-enabled offsets */
        uint_t pi_noffs;                /* number of offsets */
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to