Author: trasz Date: Fri Dec 13 18:44:02 2019 New Revision: 355723 URL: https://svnweb.freebsd.org/changeset/base/355723
Log: Add kern_kill() and use it in Linuxulator. It's just a cleanup, no functional changes. Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D22645 Modified: head/sys/compat/linux/linux_signal.c head/sys/kern/kern_sig.c head/sys/sys/syscallsubr.h Modified: head/sys/compat/linux/linux_signal.c ============================================================================== --- head/sys/compat/linux/linux_signal.c Fri Dec 13 18:39:36 2019 (r355722) +++ head/sys/compat/linux/linux_signal.c Fri Dec 13 18:44:02 2019 (r355723) @@ -415,10 +415,7 @@ linux_rt_sigtimedwait(struct thread *td, int linux_kill(struct thread *td, struct linux_kill_args *args) { - struct kill_args /* { - int pid; - int signum; - } */ tmp; + int l_signum; /* * Allow signal 0 as a means to check for privileges @@ -427,12 +424,11 @@ linux_kill(struct thread *td, struct linux_kill_args * return (EINVAL); if (args->signum > 0) - tmp.signum = linux_to_bsd_signal(args->signum); + l_signum = linux_to_bsd_signal(args->signum); else - tmp.signum = 0; + l_signum = 0; - tmp.pid = args->pid; - return (sys_kill(td, &tmp)); + return (kern_kill(td, args->pid, l_signum)); } static int Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Fri Dec 13 18:39:36 2019 (r355722) +++ head/sys/kern/kern_sig.c Fri Dec 13 18:44:02 2019 (r355723) @@ -1772,6 +1772,13 @@ struct kill_args { int sys_kill(struct thread *td, struct kill_args *uap) { + + return (kern_kill(td, uap->pid, uap->signum)); +} + +int +kern_kill(struct thread *td, pid_t pid, int signum) +{ ksiginfo_t ksi; struct proc *p; int error; @@ -1781,38 +1788,38 @@ sys_kill(struct thread *td, struct kill_args *uap) * The main rationale behind this is that abort(3) is implemented as * kill(getpid(), SIGABRT). */ - if (IN_CAPABILITY_MODE(td) && uap->pid != td->td_proc->p_pid) + if (IN_CAPABILITY_MODE(td) && pid != td->td_proc->p_pid) return (ECAPMODE); - AUDIT_ARG_SIGNUM(uap->signum); - AUDIT_ARG_PID(uap->pid); - if ((u_int)uap->signum > _SIG_MAXSIG) + AUDIT_ARG_SIGNUM(signum); + AUDIT_ARG_PID(pid); + if ((u_int)signum > _SIG_MAXSIG) return (EINVAL); ksiginfo_init(&ksi); - ksi.ksi_signo = uap->signum; + ksi.ksi_signo = signum; ksi.ksi_code = SI_USER; ksi.ksi_pid = td->td_proc->p_pid; ksi.ksi_uid = td->td_ucred->cr_ruid; - if (uap->pid > 0) { + if (pid > 0) { /* kill single process */ - if ((p = pfind_any(uap->pid)) == NULL) + if ((p = pfind_any(pid)) == NULL) return (ESRCH); AUDIT_ARG_PROCESS(p); - error = p_cansignal(td, p, uap->signum); - if (error == 0 && uap->signum) - pksignal(p, uap->signum, &ksi); + error = p_cansignal(td, p, signum); + if (error == 0 && signum) + pksignal(p, signum, &ksi); PROC_UNLOCK(p); return (error); } - switch (uap->pid) { + switch (pid) { case -1: /* broadcast signal */ - return (killpg1(td, uap->signum, 0, 1, &ksi)); + return (killpg1(td, signum, 0, 1, &ksi)); case 0: /* signal own process group */ - return (killpg1(td, uap->signum, 0, 0, &ksi)); + return (killpg1(td, signum, 0, 0, &ksi)); default: /* negative explicit process group */ - return (killpg1(td, uap->signum, -uap->pid, 0, &ksi)); + return (killpg1(td, signum, -pid, 0, &ksi)); } /* NOTREACHED */ } Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Fri Dec 13 18:39:36 2019 (r355722) +++ head/sys/sys/syscallsubr.h Fri Dec 13 18:44:02 2019 (r355723) @@ -156,6 +156,7 @@ int kern_kevent_anonymous(struct thread *td, int neven int kern_kevent_fp(struct thread *td, struct file *fp, int nchanges, int nevents, struct kevent_copyops *k_ops, const struct timespec *timeout); +int kern_kill(struct thread *td, pid_t pid, int signum); int kern_kqueue(struct thread *td, int flags, struct filecaps *fcaps); int kern_kldload(struct thread *td, const char *file, int *fileid); int kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat); _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"