summaryrefslogtreecommitdiffstats
path: root/cddl
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2014-11-17 22:22:16 +0000
committermarkj <markj@FreeBSD.org>2014-11-17 22:22:16 +0000
commit3b8560b96524208c042013355ce68add2f05f8b0 (patch)
tree8ed748023380caf51123d634925dc43ecebee478 /cddl
parent8d13dca13bd1aed4398912e6c65f720113edbbe1 (diff)
downloadFreeBSD-src-3b8560b96524208c042013355ce68add2f05f8b0.zip
FreeBSD-src-3b8560b96524208c042013355ce68add2f05f8b0.tar.gz
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
Diffstat (limited to 'cddl')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c2
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c37
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h4
3 files changed, 21 insertions, 22 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
index 5442683..0b531c5 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
@@ -469,7 +469,7 @@ dof_add_probe(dt_idhash_t *dhp, dt_ident_t *idp, void *data)
* 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);
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
index 0f1bfe0..6acb86b 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
@@ -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_probe_t *prp,
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_probe_t *prp,
(*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));
}
/*
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h
index af4ec33..2752baa 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h
@@ -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 */
OpenPOWER on IntegriCloud