Skip to content

Commit

Permalink
8880 improve DTrace error checking
Browse files Browse the repository at this point in the history
Reviewed by: Tim Kordas <tim.kordas@joyent.com>
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Dan McDonald <danmcd@joyent.com>
  • Loading branch information
jjelinek authored and Dan McDonald committed Nov 30, 2017
1 parent dfbc6f2 commit 2cf3742
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions usr/src/uts/common/dtrace/dtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -13127,6 +13127,7 @@ static int
dtrace_dof_relocate(dof_hdr_t *dof, dof_sec_t *sec, uint64_t ubase)
{
uintptr_t daddr = (uintptr_t)dof;
uintptr_t ts_end;
dof_relohdr_t *dofr =
(dof_relohdr_t *)(uintptr_t)(daddr + sec->dofs_offset);
dof_sec_t *ss, *rs, *ts;
Expand All @@ -13142,6 +13143,7 @@ dtrace_dof_relocate(dof_hdr_t *dof, dof_sec_t *sec, uint64_t ubase)
ss = dtrace_dof_sect(dof, DOF_SECT_STRTAB, dofr->dofr_strtab);
rs = dtrace_dof_sect(dof, DOF_SECT_RELTAB, dofr->dofr_relsec);
ts = dtrace_dof_sect(dof, DOF_SECT_NONE, dofr->dofr_tgtsec);
ts_end = (uintptr_t)ts + sizeof (dof_sec_t);

if (ss == NULL || rs == NULL || ts == NULL)
return (-1); /* dtrace_dof_error() has been called already */
Expand All @@ -13168,6 +13170,11 @@ dtrace_dof_relocate(dof_hdr_t *dof, dof_sec_t *sec, uint64_t ubase)
return (-1);
}

if (taddr >= (uintptr_t)ts && taddr < ts_end) {
dtrace_dof_error(dof, "bad relocation offset");
return (-1);
}

if (!IS_P2ALIGNED(taddr, sizeof (uint64_t))) {
dtrace_dof_error(dof, "misaligned setx relo");
return (-1);
Expand Down

0 comments on commit 2cf3742

Please sign in to comment.