Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_procctl.c
Show First 20 Lines • Show All 557 Lines • ▼ Show 20 Lines | if ((p->p_flag & P_WEXIT) == 0) { | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
_PRELE(p); | _PRELE(p); | ||||
} | } | ||||
*(int *)data = d; | *(int *)data = d; | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
stackgap_ctl(struct thread *td, struct proc *p, void *data) | |||||
{ | |||||
int state; | |||||
PROC_LOCK_ASSERT(p, MA_OWNED); | |||||
state = *(int *)data; | |||||
if ((state & ~(PROC_STACKGAP_ENABLE | PROC_STACKGAP_DISABLE | | |||||
PROC_STACKGAP_ENABLE_EXEC | PROC_STACKGAP_DISABLE_EXEC)) != 0) | |||||
return (EINVAL); | |||||
switch (state & (PROC_STACKGAP_ENABLE | PROC_STACKGAP_DISABLE)) { | |||||
case PROC_STACKGAP_ENABLE: | |||||
if ((p->p_flag2 & P2_STKGAP_DISABLE) != 0) | |||||
return (EINVAL); | |||||
break; | |||||
case PROC_STACKGAP_DISABLE: | |||||
p->p_flag2 |= P2_STKGAP_DISABLE; | |||||
break; | |||||
case 0: | |||||
break; | |||||
default: | |||||
return (EINVAL); | |||||
} | |||||
switch (state & (PROC_STACKGAP_ENABLE_EXEC | | |||||
PROC_STACKGAP_DISABLE_EXEC)) { | |||||
case PROC_STACKGAP_ENABLE_EXEC: | |||||
p->p_flag2 &= ~P2_STKGAP_DISABLE_EXEC; | |||||
break; | |||||
case PROC_STACKGAP_DISABLE_EXEC: | |||||
p->p_flag2 |= P2_STKGAP_DISABLE_EXEC; | |||||
break; | |||||
case 0: | |||||
break; | |||||
default: | |||||
return (EINVAL); | |||||
} | |||||
return (0); | |||||
} | |||||
static int | |||||
stackgap_status(struct thread *td, struct proc *p, void *data) | |||||
{ | |||||
int d; | |||||
PROC_LOCK_ASSERT(p, MA_OWNED); | |||||
d = (p->p_flag2 & P2_STKGAP_DISABLE) != 0 ? PROC_STACKGAP_DISABLE : | |||||
PROC_STACKGAP_ENABLE; | |||||
d |= (p->p_flag2 & P2_STKGAP_DISABLE_EXEC) != 0 ? | |||||
PROC_STACKGAP_DISABLE_EXEC : PROC_STACKGAP_ENABLE_EXEC; | |||||
*(int *)data = d; | |||||
return (0); | |||||
} | |||||
static int | |||||
wxmap_ctl(struct thread *td, struct proc *p, void *data) | wxmap_ctl(struct thread *td, struct proc *p, void *data) | ||||
{ | { | ||||
struct vmspace *vm; | struct vmspace *vm; | ||||
vm_map_t map; | vm_map_t map; | ||||
int state; | int state; | ||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
if ((p->p_flag & P_WEXIT) != 0) | if ((p->p_flag & P_WEXIT) != 0) | ||||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | [PROC_PROTMAX_CTL] = | ||||
.copyin_sz = sizeof(int), .copyout_sz = 0, | .copyin_sz = sizeof(int), .copyout_sz = 0, | ||||
.exec = protmax_ctl, .copyout_on_error = false, }, | .exec = protmax_ctl, .copyout_on_error = false, }, | ||||
[PROC_PROTMAX_STATUS] = | [PROC_PROTMAX_STATUS] = | ||||
{ .lock_tree = PCTL_UNLOCKED, .one_proc = true, | { .lock_tree = PCTL_UNLOCKED, .one_proc = true, | ||||
.esrch_is_einval = false, .no_nonnull_data = false, | .esrch_is_einval = false, .no_nonnull_data = false, | ||||
.need_candebug = false, | .need_candebug = false, | ||||
.copyin_sz = 0, .copyout_sz = sizeof(int), | .copyin_sz = 0, .copyout_sz = sizeof(int), | ||||
.exec = protmax_status, .copyout_on_error = false, }, | .exec = protmax_status, .copyout_on_error = false, }, | ||||
[PROC_STACKGAP_CTL] = | |||||
{ .lock_tree = PCTL_UNLOCKED, .one_proc = true, | |||||
.esrch_is_einval = false, .no_nonnull_data = false, | |||||
.need_candebug = true, | |||||
.copyin_sz = sizeof(int), .copyout_sz = 0, | |||||
.exec = stackgap_ctl, .copyout_on_error = false, }, | |||||
[PROC_STACKGAP_STATUS] = | |||||
{ .lock_tree = PCTL_UNLOCKED, .one_proc = true, | |||||
.esrch_is_einval = false, .no_nonnull_data = false, | |||||
.need_candebug = false, | |||||
.copyin_sz = 0, .copyout_sz = sizeof(int), | |||||
.exec = stackgap_status, .copyout_on_error = false, }, | |||||
[PROC_NO_NEW_PRIVS_CTL] = | [PROC_NO_NEW_PRIVS_CTL] = | ||||
{ .lock_tree = PCTL_SLOCKED, .one_proc = true, | { .lock_tree = PCTL_SLOCKED, .one_proc = true, | ||||
.esrch_is_einval = false, .no_nonnull_data = false, | .esrch_is_einval = false, .no_nonnull_data = false, | ||||
.need_candebug = true, | .need_candebug = true, | ||||
.copyin_sz = sizeof(int), .copyout_sz = 0, | .copyin_sz = sizeof(int), .copyout_sz = 0, | ||||
.exec = no_new_privs_ctl, .copyout_on_error = false, }, | .exec = no_new_privs_ctl, .copyout_on_error = false, }, | ||||
[PROC_NO_NEW_PRIVS_STATUS] = | [PROC_NO_NEW_PRIVS_STATUS] = | ||||
{ .lock_tree = PCTL_UNLOCKED, .one_proc = true, | { .lock_tree = PCTL_UNLOCKED, .one_proc = true, | ||||
Show All 20 Lines | |||||
{ | { | ||||
union { | union { | ||||
struct procctl_reaper_status rs; | struct procctl_reaper_status rs; | ||||
struct procctl_reaper_pids rp; | struct procctl_reaper_pids rp; | ||||
struct procctl_reaper_kill rk; | struct procctl_reaper_kill rk; | ||||
int flags; | int flags; | ||||
} x; | } x; | ||||
const struct procctl_cmd_info *cmd_info; | const struct procctl_cmd_info *cmd_info; | ||||
int error, error1; | int com, error, error1; | ||||
if (uap->com >= PROC_PROCCTL_MD_MIN) | com = uap->com; | ||||
return (cpu_procctl(td, uap->idtype, uap->id, | if (com >= PROC_PROCCTL_MD_MIN) | ||||
uap->com, uap->data)); | return (cpu_procctl(td, uap->idtype, uap->id, com, uap->data)); | ||||
if (uap->com == 0 || uap->com >= nitems(procctl_cmds_info)) | if (com < 0 || com >= nitems(procctl_cmds_info) || | ||||
procctl_cmds_info[com].exec == NULL) | |||||
return (EINVAL); | return (EINVAL); | ||||
cmd_info = &procctl_cmds_info[uap->com]; | cmd_info = &procctl_cmds_info[com]; | ||||
bzero(&x, sizeof(x)); | bzero(&x, sizeof(x)); | ||||
if (cmd_info->copyin_sz > 0) { | if (cmd_info->copyin_sz > 0) { | ||||
error = copyin(uap->data, &x, cmd_info->copyin_sz); | error = copyin(uap->data, &x, cmd_info->copyin_sz); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
} else if (cmd_info->no_nonnull_data && uap->data != NULL) { | } else if (cmd_info->no_nonnull_data && uap->data != NULL) { | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
error = kern_procctl(td, uap->idtype, uap->id, uap->com, &x); | error = kern_procctl(td, uap->idtype, uap->id, com, &x); | ||||
if (cmd_info->copyout_sz > 0 && (error == 0 || | if (cmd_info->copyout_sz > 0 && (error == 0 || | ||||
cmd_info->copyout_on_error)) { | cmd_info->copyout_on_error)) { | ||||
error1 = copyout(&x, uap->data, cmd_info->copyout_sz); | error1 = copyout(&x, uap->data, cmd_info->copyout_sz); | ||||
if (error == 0) | if (error == 0) | ||||
error = error1; | error = error1; | ||||
} | } | ||||
return (error); | return (error); | ||||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |