aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_prot.c
diff options
context:
space:
mode:
authorMaxim Sobolev <sobomax@FreeBSD.org>2005-03-03 16:57:55 +0000
committerMaxim Sobolev <sobomax@FreeBSD.org>2005-03-03 16:57:55 +0000
commit4b1783363f35aba054a2acba107a05cbbb8db3d2 (patch)
treeba29913230380c4c6bf7753c0c677cca210d631f /sys/kern/kern_prot.c
parent24fe1eafe40885832b441a5b7278eec2f9b2919b (diff)
downloadsrc-4b1783363f35aba054a2acba107a05cbbb8db3d2.tar.gz
src-4b1783363f35aba054a2acba107a05cbbb8db3d2.zip
In linux emulation layer try to detect attempt to use linux_clone() to
create kernel threads and call rfork(2) with RFTHREAD flag set in this case, which puts parent and child into the same threading group. As a result all threads that belong to the same program end up in the same threading group. This is similar to what linuxthreads port does, though in this case we don't have a luxury of having access to the source code and there is no definite way to differentiate linux_clone() called for threading purposes from other uses, so that we have to resort to heuristics. Allow SIGTHR to be delivered between all processes in the same threading group previously it has been blocked for s[ug]id processes. This also should improve locking of the same file descriptor from different threads in programs running under linux compat layer. PR: kern/72922 Reported by: Andriy Gapon <avg@icyb.net.ua> Idea suggested by: rwatson
Notes
Notes: svn path=/head/; revision=143108
Diffstat (limited to 'sys/kern/kern_prot.c')
-rw-r--r--sys/kern/kern_prot.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index 38b904282ac1..9c6cd09c68c3 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -1523,6 +1523,18 @@ p_cansignal(struct thread *td, struct proc *p, int signum)
/* XXX: This will require an additional lock of some sort. */
if (signum == SIGCONT && td->td_proc->p_session == p->p_session)
return (0);
+ /*
+ * Some compat layers use SIGTHR for communications between
+ * different kernel threads of the same process, so that
+ * they are expecting that it's always possible to deliver
+ * it, even for suid applications where cr_cansignal() can
+ * deny such ability for security consideration. It should be
+ * pretty safe to do since the only way to create two processes
+ * with the same p_leader is via rfork(2).
+ */
+ if (signum == SIGTHR && td->td_proc->p_leader != NULL &&
+ td->td_proc->p_leader == p->p_leader)
+ return (0);
return (cr_cansignal(td->td_ucred, p, signum));
}