Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/freebsd32/freebsd32_misc.c
| Show First 20 Lines • Show All 997 Lines • ▼ Show 20 Lines | |||||
| ptrace_sc_ret_to32(const struct ptrace_sc_ret *psr, | ptrace_sc_ret_to32(const struct ptrace_sc_ret *psr, | ||||
| struct ptrace_sc_ret32 *psr32) | struct ptrace_sc_ret32 *psr32) | ||||
| { | { | ||||
| bzero(psr32, sizeof(*psr32)); | bzero(psr32, sizeof(*psr32)); | ||||
| psr32->sr_retval[0] = psr->sr_retval[0]; | psr32->sr_retval[0] = psr->sr_retval[0]; | ||||
| psr32->sr_retval[1] = psr->sr_retval[1]; | psr32->sr_retval[1] = psr->sr_retval[1]; | ||||
| psr32->sr_error = psr->sr_error; | psr32->sr_error = psr->sr_error; | ||||
| } | |||||
| static void | |||||
| ptrace_sc_ret32_to_ret(const struct ptrace_sc_ret32 *psr32, | |||||
| struct ptrace_sc_ret *psr) | |||||
| { | |||||
| bzero(psr, sizeof(*psr)); | |||||
| psr->sr_retval[0] = psr32->sr_retval[0]; | |||||
| psr->sr_retval[1] = psr32->sr_retval[1]; | |||||
| psr->sr_error = psr32->sr_error; | |||||
| } | } | ||||
| int | int | ||||
| freebsd32_ptrace(struct thread *td, struct freebsd32_ptrace_args *uap) | freebsd32_ptrace(struct thread *td, struct freebsd32_ptrace_args *uap) | ||||
| { | { | ||||
| union { | union { | ||||
| struct ptrace_io_desc piod; | struct ptrace_io_desc piod; | ||||
| struct ptrace_lwpinfo pl; | struct ptrace_lwpinfo pl; | ||||
| Show All 32 Lines | freebsd32_ptrace(struct thread *td, struct freebsd32_ptrace_args *uap) | ||||
| AUDIT_ARG_VALUE(uap->data); | AUDIT_ARG_VALUE(uap->data); | ||||
| addr = &r; | addr = &r; | ||||
| data = uap->data; | data = uap->data; | ||||
| switch (uap->req) { | switch (uap->req) { | ||||
| case PT_GET_EVENT_MASK: | case PT_GET_EVENT_MASK: | ||||
| case PT_GET_SC_ARGS: | case PT_GET_SC_ARGS: | ||||
| case PT_GET_SC_RET: | case PT_GET_SC_RET: | ||||
| break; | break; | ||||
| case PT_SET_SC_RET: | |||||
| error = copyin(uap->addr, &r32.psr, MIN(uap->data, | |||||
markj: Shouldn't we require `uap->data == sizeof(r32.psr)`? If `uap->data` is smaller, we'll copy… | |||||
| sizeof(r32.psr))); | |||||
| if (error == 0) | |||||
| ptrace_sc_ret32_to_ret(&r32.psr, &r.psr); | |||||
| break; | |||||
| case PT_LWPINFO: | case PT_LWPINFO: | ||||
| if (uap->data > sizeof(r32.pl)) | if (uap->data > sizeof(r32.pl)) | ||||
| return (EINVAL); | return (EINVAL); | ||||
| /* | /* | ||||
| * Pass size of native structure in 'data'. Truncate | * Pass size of native structure in 'data'. Truncate | ||||
| * if necessary to avoid siginfo. | * if necessary to avoid siginfo. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 3,179 Lines • Show Last 20 Lines | |||||
Shouldn't we require uap->data == sizeof(r32.psr)? If uap->data is smaller, we'll copy uninitialized stack bytes into the native struct.