int sys__lwp_kill(struct lwp *l, const struct sys__lwp_kill_args *uap, register_t *retval) { /* { syscallarg(lwpid_t) target; syscallarg(int) signo; } */ struct proc *p = l->l_proc; struct lwp *t; ksiginfo_t ksi; int signo = SCARG(uap, signo); int error = 0; if ((u_int)signo >= NSIG) return EINVAL; KSI_INIT(&ksi); ksi.ksi_signo = signo; ksi.ksi_code = SI_LWP; ksi.ksi_pid = p->p_pid; ksi.ksi_uid = kauth_cred_geteuid(l->l_cred); ksi.ksi_lid = SCARG(uap, target); mutex_enter(proc_lock); mutex_enter(p->p_lock); if ((t = lwp_find(p, ksi.ksi_lid)) == NULL) error = ESRCH; else if (signo != 0) kpsignal2(p, &ksi); mutex_exit(p->p_lock); mutex_exit(proc_lock); return error; }
void db_kill_proc(db_expr_t addr, bool haddr, db_expr_t count, const char *modif) { #ifdef _KERNEL /* XXX CRASH(8) */ struct proc *p; ksiginfo_t ksi; db_expr_t pid, sig; int t; /* What pid? */ if (!db_expression(&pid)) { db_error("pid?\n"); /*NOTREACHED*/ } /* What sig? */ t = db_read_token(); if (t == tCOMMA) { if (!db_expression(&sig)) { db_error("sig?\n"); /*NOTREACHED*/ } } else { db_unread_token(t); sig = 15; } if (db_read_token() != tEOL) { db_error("?\n"); /*NOTREACHED*/ } /* We might stop when the mutex is held or when not */ t = mutex_tryenter(proc_lock); #ifdef DIAGNOSTIC if (!t) { db_error("could not acquire proc_lock mutex\n"); /*NOTREACHED*/ } #endif p = proc_find((pid_t)pid); if (p == NULL) { if (t) mutex_exit(proc_lock); db_error("no such proc\n"); /*NOTREACHED*/ } KSI_INIT(&ksi); ksi.ksi_signo = sig; ksi.ksi_code = SI_USER; ksi.ksi_pid = 0; ksi.ksi_uid = 0; mutex_enter(p->p_lock); kpsignal2(p, &ksi); mutex_exit(p->p_lock); if (t) mutex_exit(proc_lock); #else db_printf("This command is not currently supported.\n"); #endif }
int sys_kill(struct lwp *l, const struct sys_kill_args *uap, register_t *retval) { /* { syscallarg(pid_t) pid; syscallarg(int) signum; } */ ksiginfo_t ksi; KSI_INIT(&ksi); ksi.ksi_signo = SCARG(uap, signum); ksi.ksi_code = SI_USER; ksi.ksi_pid = l->l_proc->p_pid; ksi.ksi_uid = kauth_cred_geteuid(l->l_cred); return kill1(l, SCARG(uap, pid), &ksi, retval); }
int sys_sigqueueinfo(struct lwp *l, const struct sys_sigqueueinfo_args *uap, register_t *retval) { /* { syscallarg(pid_t int) pid; syscallarg(const siginfo_t *) info; } */ ksiginfo_t ksi; int error; KSI_INIT(&ksi); if ((error = copyin(&SCARG(uap, info)->_info, &ksi.ksi_info, sizeof(ksi.ksi_info))) != 0) return error; return kill1(l, SCARG(uap, pid), &ksi, retval); }
static int linux_do_tkill(struct lwp *l, int tgid, int tid, int signum) { struct proc *p; struct lwp *t; ksiginfo_t ksi; int error; if (signum < 0 || signum >= LINUX__NSIG) return EINVAL; signum = linux_to_native_signo[signum]; if (tgid == -1) { tgid = tid; } KSI_INIT(&ksi); ksi.ksi_signo = signum; ksi.ksi_code = SI_LWP; ksi.ksi_pid = l->l_proc->p_pid; ksi.ksi_uid = kauth_cred_geteuid(l->l_cred); ksi.ksi_lid = tid; mutex_enter(proc_lock); p = proc_find(tgid); if (p == NULL) { mutex_exit(proc_lock); return ESRCH; } mutex_enter(p->p_lock); error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_SIGNAL, p, KAUTH_ARG(signum), NULL, NULL); if ((t = lwp_find(p, ksi.ksi_lid)) == NULL) error = ESRCH; else if (signum != 0) kpsignal2(p, &ksi); mutex_exit(p->p_lock); mutex_exit(proc_lock); return error; }
int netbsd32_sigqueueinfo(struct lwp *l, const struct netbsd32_sigqueueinfo_args *uap, register_t *retval) { /* { syscallarg(pid_t) pid; syscallarg(const netbsd32_siginfop_t) info; } */ struct __ksiginfo32 ksi32; ksiginfo_t ksi; int error; if ((error = copyin(SCARG_P32(uap, info), &ksi32, sizeof(ksi32))) != 0) return error; KSI_INIT(&ksi); netbsd32_ksi32_to_ksi(&ksi.ksi_info, &ksi32); return kill1(l, SCARG(uap, pid), &ksi, retval); }