Remove the DTRACEHIOC_ADD ioctl.

This ioctl has been considered legacy by upstream since the DTrace code
was first imported, and is unused. The removal also allows some
simplification of dtrace_helper_slurp().

Also remove a bogus copyout in the DTRACEHIOC_ADDDOF handler. Due to a
bug, it would overwrite an in-memory copy of the DOF header rather than
the passed-in DOF helper. Moreover, DTRACEHIOC_ADDDOF already copies the
helper back out automatically since its argument has the IOC_OUT attribute.
This commit is contained in:
Mark Johnston 2017-01-23 02:21:06 +00:00
parent 98ff1f7c6e
commit 792e2f09ee
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=312658
3 changed files with 17 additions and 32 deletions

View File

@ -16255,18 +16255,11 @@ dtrace_helper_provider_validate(dof_hdr_t *dof, dof_sec_t *sec)
}
static int
#ifdef __FreeBSD__
dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp, struct proc *p)
#else
dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp)
#endif
{
dtrace_helpers_t *help;
dtrace_vstate_t *vstate;
dtrace_enabling_t *enab = NULL;
#ifndef __FreeBSD__
proc_t *p = curproc;
#endif
int i, gen, rv, nhelpers = 0, nprovs = 0, destroy = 1;
uintptr_t daddr = (uintptr_t)dof;
@ -16277,8 +16270,8 @@ dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp)
vstate = &help->dthps_vstate;
if ((rv = dtrace_dof_slurp(dof, vstate, NULL, &enab,
dhp != NULL ? dhp->dofhp_addr : 0, B_FALSE)) != 0) {
if ((rv = dtrace_dof_slurp(dof, vstate, NULL, &enab, dhp->dofhp_addr,
B_FALSE)) != 0) {
dtrace_dof_destroy(dof);
return (rv);
}
@ -16286,22 +16279,20 @@ dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp)
/*
* Look for helper providers and validate their descriptions.
*/
if (dhp != NULL) {
for (i = 0; i < dof->dofh_secnum; i++) {
dof_sec_t *sec = (dof_sec_t *)(uintptr_t)(daddr +
dof->dofh_secoff + i * dof->dofh_secsize);
for (i = 0; i < dof->dofh_secnum; i++) {
dof_sec_t *sec = (dof_sec_t *)(uintptr_t)(daddr +
dof->dofh_secoff + i * dof->dofh_secsize);
if (sec->dofs_type != DOF_SECT_PROVIDER)
continue;
if (sec->dofs_type != DOF_SECT_PROVIDER)
continue;
if (dtrace_helper_provider_validate(dof, sec) != 0) {
dtrace_enabling_destroy(enab);
dtrace_dof_destroy(dof);
return (-1);
}
nprovs++;
if (dtrace_helper_provider_validate(dof, sec) != 0) {
dtrace_enabling_destroy(enab);
dtrace_dof_destroy(dof);
return (-1);
}
nprovs++;
}
/*
@ -16342,7 +16333,7 @@ dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp)
gen = help->dthps_generation++;
dtrace_enabling_destroy(enab);
if (dhp != NULL && nprovs > 0) {
if (nprovs > 0) {
/*
* Now that this is in-kernel, we change the sense of the
* members: dofhp_dof denotes the in-kernel copy of the DOF

View File

@ -1410,7 +1410,6 @@ typedef struct {
#define DTRACEHIOC_REMOVE (DTRACEHIOC | 2) /* remove helper */
#define DTRACEHIOC_ADDDOF (DTRACEHIOC | 3) /* add helper DOF */
#else
#define DTRACEHIOC_ADD _IOWR('z', 1, dof_hdr_t)/* add helper */
#define DTRACEHIOC_REMOVE _IOW('z', 2, int) /* remove helper */
#define DTRACEHIOC_ADDDOF _IOWR('z', 3, dof_helper_t)/* add helper DOF */
#endif

View File

@ -44,10 +44,8 @@ dtrace_ioctl_helper(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
case DTRACEHIOC_ADDDOF:
dhp = (dof_helper_t *)addr;
addr = (caddr_t)(uintptr_t)dhp->dofhp_dof;
/* FALLTHROUGH */
case DTRACEHIOC_ADD:
p = curproc;
if (dhp == NULL || p->p_pid == dhp->dofhp_pid) {
if (p->p_pid == dhp->dofhp_pid) {
p = curproc;
dof = dtrace_dof_copyin((uintptr_t)addr, &rval);
} else {
p = pfind(dhp->dofhp_pid);
@ -72,10 +70,7 @@ dtrace_ioctl_helper(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
mutex_enter(&dtrace_lock);
if ((rval = dtrace_helper_slurp(dof, dhp, p)) != -1) {
if (dhp != NULL) {
dhp->dofhp_gen = rval;
copyout(dhp, addr, sizeof(*dhp));
}
dhp->dofhp_gen = rval;
rval = 0;
} else {
rval = EINVAL;