From 3bef33deb1cdabea1b8761a141f28259edcd46bc Mon Sep 17 00:00:00 2001 From: bruno Date: Mon, 1 Mar 2010 14:27:16 +0000 Subject: Deliver siginfo when signal is generated by thr_kill(2) (SI_USER with properly filled si_uid and si_pid). Reported by: Joel Bertrand PR: 141956 Reviewed by: kib MFC after: 2 weeks --- sys/kern/kern_thr.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'sys/kern/kern_thr.c') diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 3159a91..116e79b 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -303,12 +303,18 @@ int thr_kill(struct thread *td, struct thr_kill_args *uap) /* long id, int sig */ { + ksiginfo_t ksi; struct thread *ttd; struct proc *p; int error; p = td->td_proc; error = 0; + ksiginfo_init(&ksi); + ksi.ksi_signo = uap->sig; + ksi.ksi_code = SI_USER; + ksi.ksi_pid = p->p_pid; + ksi.ksi_uid = td->td_ucred->cr_ruid; PROC_LOCK(p); if (uap->id == -1) { if (uap->sig != 0 && !_SIG_VALID(uap->sig)) { @@ -320,7 +326,7 @@ thr_kill(struct thread *td, struct thr_kill_args *uap) error = 0; if (uap->sig == 0) break; - tdsignal(p, ttd, uap->sig, NULL); + tdsignal(p, ttd, uap->sig, &ksi); } } } @@ -336,7 +342,7 @@ thr_kill(struct thread *td, struct thr_kill_args *uap) else if (!_SIG_VALID(uap->sig)) error = EINVAL; else - tdsignal(p, ttd, uap->sig, NULL); + tdsignal(p, ttd, uap->sig, &ksi); } PROC_UNLOCK(p); return (error); @@ -346,6 +352,7 @@ int thr_kill2(struct thread *td, struct thr_kill2_args *uap) /* pid_t pid, long id, int sig */ { + ksiginfo_t ksi; struct thread *ttd; struct proc *p; int error; @@ -362,6 +369,11 @@ thr_kill2(struct thread *td, struct thr_kill2_args *uap) error = p_cansignal(td, p, uap->sig); if (error == 0) { + ksiginfo_init(&ksi); + ksi.ksi_signo = uap->sig; + ksi.ksi_code = SI_USER; + ksi.ksi_pid = td->td_proc->p_pid; + ksi.ksi_uid = td->td_ucred->cr_ruid; if (uap->id == -1) { if (uap->sig != 0 && !_SIG_VALID(uap->sig)) { error = EINVAL; @@ -372,7 +384,8 @@ thr_kill2(struct thread *td, struct thr_kill2_args *uap) error = 0; if (uap->sig == 0) break; - tdsignal(p, ttd, uap->sig, NULL); + tdsignal(p, ttd, uap->sig, + &ksi); } } } @@ -388,7 +401,7 @@ thr_kill2(struct thread *td, struct thr_kill2_args *uap) else if (!_SIG_VALID(uap->sig)) error = EINVAL; else - tdsignal(p, ttd, uap->sig, NULL); + tdsignal(p, ttd, uap->sig, &ksi); } } PROC_UNLOCK(p); -- cgit v1.1