1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-27 08:00:11 +00:00

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
This commit is contained in:
Mark Johnston 2014-11-17 22:22:16 +00:00
parent 4facd36ca0
commit af62c4ddd0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=274637
3 changed files with 21 additions and 22 deletions

View File

@ -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);

View File

@ -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));
}
/*

View File

@ -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 */