summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2019-12-13 18:44:02 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2019-12-13 18:44:02 +0000
commit34ad5ac2428d75bd37d9446ebce64be3ca08a999 (patch)
tree12ac2aa9e5212387fbf15febfd6b1b5163c9b53a
parentbe2cfdbc868fa0368d97ce14b6dd2e55185d7aea (diff)
Notes
-rw-r--r--sys/compat/linux/linux_signal.c12
-rw-r--r--sys/kern/kern_sig.c35
-rw-r--r--sys/sys/syscallsubr.h1
3 files changed, 26 insertions, 22 deletions
diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c
index 441a03613d0c..365fceb0ad42 100644
--- a/sys/compat/linux/linux_signal.c
+++ b/sys/compat/linux/linux_signal.c
@@ -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 *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
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index dc97c0388d17..203c47bea360 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -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 */
}
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index c6c57723e02b..c883f66823fe 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -156,6 +156,7 @@ int kern_kevent_anonymous(struct thread *td, int nevents,
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);