Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Mar 2010 14:27:16 +0000 (UTC)
From:      Bruno Ducrot <bruno@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r204519 - head/sys/kern
Message-ID:  <201003011427.o21ERGkq024388@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bruno
Date: Mon Mar  1 14:27:16 2010
New Revision: 204519
URL: http://svn.freebsd.org/changeset/base/204519

Log:
  Deliver siginfo when signal is generated by thr_kill(2) (SI_USER with properly
  filled si_uid and si_pid).
  
  Reported by:	Joel Bertrand <joel.bertrand systella fr>
  PR:		141956
  Reviewed by:	kib
  MFC after:	2 weeks

Modified:
  head/sys/kern/kern_thr.c

Modified: head/sys/kern/kern_thr.c
==============================================================================
--- head/sys/kern/kern_thr.c	Mon Mar  1 13:56:15 2010	(r204518)
+++ head/sys/kern/kern_thr.c	Mon Mar  1 14:27:16 2010	(r204519)
@@ -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_k
 					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_k
 		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_
 
 	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_
 						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_
 			else if (!_SIG_VALID(uap->sig))
 				error = EINVAL;
 			else
-				tdsignal(p, ttd, uap->sig, NULL);
+				tdsignal(p, ttd, uap->sig, &ksi);
 		}
 	}
 	PROC_UNLOCK(p);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003011427.o21ERGkq024388>